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,068
  • 9
  • 42
  • 88

1 Answers1

1

You want instead:

(datetime.now() - timedelta(hours=24)).strftime('%Y-%m-%d %H:%M:%S')
mechanical_meat
  • 155,494
  • 24
  • 217
  • 209