TypeError: ‘>’ not supported between instances of ‘datetime.datetime’ and ‘str’

You have to use strptime to convert a string into a date.

The comparaison operator only applies between datetime.

date = datetime.strptime('2018-11-10 10:55:31', '%Y-%m-%d %H:%M:%S')

then can you do

if past > date :
   print("This is older than 90 days")

Leave a Comment