Skip to Content
Menu
This question has been flagged
3 Replies
1826 Rodiniai

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 

Portretas
Atmesti
Best Answer

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

Portretas
Atmesti
Autorius Best Answer

dont working :/

Portretas
Atmesti
Best Answer

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


Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
0
vas. 24
1278
2
vas. 19
7785
0
kov. 16
4187
2
rugs. 23
5153
1
spal. 18
4675