跳至内容
菜单
此问题已终结
3 回复
1962 查看

HOW I CAN CALCULATE DIFFERENCE BETWEEN TWO DATE

I HAVE A CHAMP X_STUDIO_DATE_DEPART AND X_STUDIO_DATE_ARRIVE

AND I WANT TO CALCULATE THE DEFERENCE BETWEEN TWO DAYS IN X_STUDIO_TOTAL_DAYS 

CAN 

形象
丢弃
最佳答案

Hello,

Please check out the following documentation.
https://www.geeksforgeeks.org/python-program-to-find-number-of-days-between-two-given-dates/

Hope it helps.

Thanks,
info@creyox.com

形象
丢弃
编写者 最佳答案

dont working :/

形象
丢弃
最佳答案

Hi 

you can use a compute function for X_STUDIO_TOTAL_DAYS 

if record.x_studio_date_depart > record.x_studio_date_arrive:
raise ValidationError('Depart should not be greater than the Arrive.')
else:
start_date = datetime.strptime(record.x_studio_date_depart, '%Y-%m-%d')
end_date = datetime.strptime(record.x_studio_date_arrive, '%Y-%m-%d')
delta = end_date - start_date
record.x_studio_total_days = delta.days


Regards


形象
丢弃
相关帖文 回复 查看 活动
0
2月 24
1428
2
2月 19
7948
0
3月 16
4307
2
9月 23
5384
1
10月 18
4806