0

I want to calculate the number of days till today from this list.

dateslist = [datetime.date(2014, 11, 5), datetime.date(2014, 11, 5), datetime.date(2014, 11, 17), datetime.date(2014, 11, 5)]

Edit: This question was marked duplicate. But I wanted to calculate the number of days, not the time.
I was able to solve this one. Here is the code for reference.

no_of_days = []
for a in dateslist:
    no_of_days.append((datetime.date(2019,1,12) - a).days)
Rishab Gupta
  • 561
  • 3
  • 17

1 Answers1

3

You can generate a list of dates by the following:

import datetime as dt

daysTillToday = [(dt.datetime.now() - r).days for r in dateslist]
tnknepp
  • 5,888
  • 6
  • 43
  • 57