跳至內容
選單
此問題已被標幟
3 回覆
1804 瀏覽次數

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
1262
2
2月 19
7756
0
3月 16
4165
2
9月 23
5135
1
10月 18
4647