Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RenSys/62fc9ef8e5367bbdd4b44fc9e0f1e7ff to your computer and use it in GitHub Desktop.
Save RenSys/62fc9ef8e5367bbdd4b44fc9e0f1e7ff to your computer and use it in GitHub Desktop.
Calc first & last day of previous month
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