Last active
February 17, 2017 08:34
-
-
Save RenSys/62fc9ef8e5367bbdd4b44fc9e0f1e7ff to your computer and use it in GitHub Desktop.
Calc first & last day of previous month
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pendulum | |
# pip install pendulum | |
if __name__ == '__main__': | |
_1st_day = pendulum.now().subtract(months=1).start_of('month') | |
last_day = pendulum.now().subtract(months=1).end_of('month') | |
print 'First day of previous month: {}'.format(_1st_day.to_date_string()) | |
print 'Last day of previous month: {}'.format(last_day.to_date_string()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment