How Compute # of Days between Two Dates?

Michael Tobis mtobis at gmail.com
Mon Sep 1 05:03:04 CEST 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