Created
February 25, 2020 11:17
-
-
Save idlesign/6c172cfa045af518856a2bdd28ebc0cb to your computer and use it in GitHub Desktop.
Get months count since date
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
from datetime import datetime | |
from dateutil import relativedelta | |
def get_months(since): | |
delta = relativedelta.relativedelta(datetime.now(), since) | |
months = delta.months + (delta.years * 12) | |
return months | |
months = get_months(datetime(2014, 9, 1)) | |
print(months) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment