How Compute # of Days between Two Dates?

Michael Tobis mtobis at gmail.com
Sun Aug 31 23:03:04 EDT 2008


from datetime import datetime

# batteries included

today = datetime.now()
xmas = datetime(today.year,12,25)
if (xmas - today).days > 1:
   print "%d days until Christmas" % (xmas - today).days
else:
   print "Merry Christmas!"



More information about the Python-list mailing list