It functions with the current date.
How can I get the duration based on the date and time?
for myself:
if both i.start_date and i.end_date exist:
Datetime.strptime(str(i.start_date), "%Y-%m-%d %H:%M:%S").date(); s_date = datetime.strptime()
Datetime.strptime(str(i.end_date), "%Y-%m-%d %H:%M:%S").date() yields e_date.
If the date is smaller than the e-date, then
(e_date - s_date) is the outcome.
i.duration = outcome
alternatively:
message = f"{s_date} Needs to be preceding {e_date}."
message = raise UserError