Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python's datetime and end of the month

How to create datetime object representing the very last moment of the current month ?

like image 723
Konstantin Avatar asked Dec 03 '22 07:12

Konstantin


1 Answers

Use a simple trick: Set the date to the first of the next month and then subtract one second/hour/day/as much as you need.

like image 82
Aaron Digulla Avatar answered Dec 15 '22 00:12

Aaron Digulla