1

I need to compare the modification date of a file with a date that comes from a table, but the method I'm using is not the best, can you help?

Right now I'm doing this:

modificationTime = time.strftime('%d/%m/%Y', time.localtime(os.path.getmtime(file))) 

max_load_date = (engine.execute("SELECT MAX(load_date) from %s where filename = '%s'" % (table, os.path.basename(file)))).first()[0]

print(max_load_date < modificationTime)

it's flawless because 23/05/2022 is bigger than 22/05/2022, but if 23/05/2022 it's smaller than 24/04/2022.

I've tried to convert the date coming from the database, but failed...

I've tried something like this

time.strftime('%d/%m/%Y', max_load_date)

but it doesn't work

Catarina Ribeiro
  • 562
  • 2
  • 16

0 Answers0