Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
1922 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Autore Risposta migliore

dont working :/

Avatar
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
feb 24
1410
2
feb 19
7922
0
mar 16
4285
2
set 23
5325
1
ott 18
4793