Skip to content

Instantly share code, notes, and snippets.

@idlesign
Created February 25, 2020 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idlesign/6c172cfa045af518856a2bdd28ebc0cb to your computer and use it in GitHub Desktop.
Save idlesign/6c172cfa045af518856a2bdd28ebc0cb to your computer and use it in GitHub Desktop.
Get months count since date
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