1

I have tried something like this:

datetime.strftime('%Y-%m-%d %H:%M:%S',(datetime.now() - timedelta(hours=24))

I just want to get a MySQL formatted string for yesterday. The above is not working as strftime expects a datetime.date and I gave a string.

ComputerLocus
  • 3,448
  • 10
  • 47
  • 96

1 Answers1

1

You want instead:

(datetime.now() - timedelta(hours=24)).strftime('%Y-%m-%d %H:%M:%S')
mechanical_meat
  • 163,903
  • 24
  • 228
  • 223