How to prompt user for two dates and output date difference in YY, M, DD?
<p>I have been searching for a clarified answer on this. I have read many threads and other websites about using datetime, but how can I build a simple program that prompts a user for two certain dates, and then calculate the difference between those dates? I am stuck on figuring out how to get the month and days.</p>

<p>This is what I have so far:</p>

<pre><code>print ("How old will you be when you graduate?")
print ("If you want to know, I'll have to ask you a few questions.")

name = input('What is your name? ')

bYear = int(input("What year were you born? "))

print ("Don't worry. Your information is safe with me.")

bMonth = int(input("What month were you born? "))
bDay = int(input("How about the day you were born? "))

print ("Fantastic. We're almost done here.")

gYear = int(input("What year do you think you'll graduate? "))
gMonth = int(input("What about the month? "))
gDay = int(input("While you're at it, give me the day too. "))


age = gYear - bYear

if bMonth &gt; gMonth:
    age = age - 1
    aMonth = 
if bMonth == gMonth and bDay &gt; gDay:
    age = age - 1

print(name, 'you will be', age, 'years old by the time you graduate. Thanks for the information.')
</code></pre>

<p>I am just beginning to use Python, but it's seems pretty simple just coming in. So, for example I want to prompt the user for the year they were born, the month they were born, and the day they were born. Then I want to prompt the user for the year they will graduate, the month they will graduate, and the day they will graduate. Then I want the program to calculate the difference between those dates and output the age of the person in years, months, and days. </p>

<p>For example</p>

<pre><code>BORN AUGUST 23, 1995
WILL GRADUATE: JUNE 11, 2018
AGE AT GRADUATION : 22 YEARS 9 MONTHS AND 18 DAYS
</code></pre>

<p>You can use the <code>datetime</code> and <a href="http://dateutil.readthedocs.io/en/stable/index.html" rel="nofollow"><code>dateutil</code></a> modules. <code>datetime</code> is in the Python standard library, however, <code>dateutil</code> is 3rd party - it can be installed with pip.</p>

<pre><code>from datetime import date
from dateutil.relativedelta import relativedelta

birth_date = date(year=1992, month=12, day=21)
graduation_date = date(year=2016, month=9, day=28)
diff = relativedelta(graduation_date, birth_date)

&gt;&gt;&gt; print(diff)
relativedelta(years=+23, months=+9, days=+7)
&gt;&gt;&gt; print('AGE AT GRADUATION : {0.years} YEARS {0.months} MONTHS AND {0.days} DAYS'.format(diff))
AGE AT GRADUATION : 23 YEARS 9 MONTHS AND 7 DAYS
</code></pre>

python datetime difference