I have 2 dates I want the no of days between the 2 dates how to retrieve that
expiry_date = details['expires']
today = date.today().strftime("%d/%m/%Y")
For example
28/11/2021
29/11/2021
no.of.days=1
I have 2 dates I want the no of days between the 2 dates how to retrieve that
expiry_date = details['expires']
today = date.today().strftime("%d/%m/%Y")
For example
28/11/2021
29/11/2021
no.of.days=1
If you have two datetime
objects, you can subtract them to get a timedelta
.
diff = (datetime.datetime.strptime("29/11/2021", "%d/%m/%Y") -
datetime.datetime.strptime("28/11/2021", "%d/%m/%Y"))
You can then convert to days:
diff.total_seconds() / 86400.
Search for the answer yourself first, then ask if you can't find anything.
How to calculate number of days between two given dates
Use this