Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
1781 Zobrazení

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 

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Autor Nejlepší odpověď

dont working :/

Avatar
Zrušit
Nejlepší odpověď

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


Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
úno 24
1247
2
úno 19
7739
0
bře 16
4146
2
zář 23
5078
1
říj 18
4630