Kanchon Gharami
Kanchon Gharami

Reputation: 949

Comparing Datetime in Django

I am working with Django. My database has a Schedule table with the following fields:

It means that any work starts at startingTime and lasts for durationInMinits (numeric value, in minute unit).

If a work is started at April 22, 2021, 6 p.m. and it's durationInMinits is 30 minutes, then it will running till April 22, 2021, 6:30 p.m.

I need to determine, does the work running time belong to the current time?

Here I will determine current time by using timezone.now() function. kindly provide any suggestion to determine it.

Upvotes: 1

Views: 77

Answers (1)

Shubham Agrawal
Shubham Agrawal

Reputation: 427

This will send that your current time belongs to your defined range

startingTime <= timezone.now() < startingTime + timezone.timedelta(minutes=durationInMinits)

Upvotes: 2

Related Questions