0

I ve been trying to compare two dates:

i get the first with:

    now =  datetime.datetime.now()
    data_loc=datetime.date(now.year,now.month,now.day)

the second one like:

    date_to_compare=datetime.date(2018,2,13)

now i would like something like that:

    if (data_loc-date_to_compare) < 60:
        do something

This is the error i get:

TypeError: '<' not supported between instances of 'datetime.timedelta' and 'int'

Alessandro Bovo
  • 345
  • 2
  • 15

1 Answers1

5

You have to compare timedelta to another timedelta:

if (data_loc-date_to_compare) < datetime.timedelta(days=60):
blhsing
  • 91,368
  • 6
  • 71
  • 106