Skip to content

Instantly share code, notes, and snippets.

@moanesga
Last active June 2, 2018 12:55
Show Gist options
  • Save moanesga/22f83cbbd7da44d954829da87e577ea5 to your computer and use it in GitHub Desktop.
Save moanesga/22f83cbbd7da44d954829da87e577ea5 to your computer and use it in GitHub Desktop.
Calculating range between tho given dates and printing result in X years X months X days
from datetime import datetime
from dateutil import relativedelta
a = datetime(1985,1,1)
b = datetime(2000,1,28)
delta = relativedelta.relativedelta(b,a)
years = delta.years
months = delta.months
days = delta.days
print("Range of variable hire_date is",years, "years",months, "months", days, "days")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment