0

how can I set a month date to appear with last day of month. Currently I have

 2008-01-01 for January

but I want it

 2008-01-31. 

Thanks in advance

1 Answers1

0

Use replace of datetime module

import datetime
datetime.datetime.strptime('2008-01-01','%Y-%d-%m').replace(day=31)
mad_
  • 8,121
  • 2
  • 25
  • 40