Created
January 18, 2017 10:38
-
-
Save casimir/36bfd01bf070877895dfc23536a1ca15 to your computer and use it in GitHub Desktop.
A whole new year
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 datetime as dt | |
def last_month(): | |
last_eom = dt.date.today().replace(day=1) - dt.timedelta(days=1) | |
to_date = last_eom + dt.timedelta(days=1) | |
from_date = last_eom.replace(day=1) | |
return from_date, to_date | |
# >>> print(dt.date.today()) | |
# 2017-01-18 | |
# >>> fdate, tdate = last_month() | |
# >>> print(fdate) | |
# 2016-12-01 | |
# >>> print(tdate) | |
# 2017-01-01 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment