Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Program to read birthdate and display birthday month and calculate days till next birthday
#Read birthdate and display birthday manth
import datetime
birthday=input("What is your birthday date['yyyy-mm-dd' format] ")
birthday=datetime.datetime.strptime(birthday,"%Y-%m-%d").date()
print("Birthday month is "+birthday.strftime('%B'))
#read next birthday and display number of days left till next birthday
import datetime
birthday=input("When is your next birthday ['yyyy-mm-dd' format] : ")
birthday=datetime.datetime.strptime(birthday,"%Y-%m-%d").date()
CurrentDay=datetime.date.today()
diff=birthday-CurrentDay
print("There are {0:} day(s) left till your next Birthday".format(diff.days))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment