hello,
i just want to find difference between two dates interms of days by getting dates as a user input. i tried getting user input using raw_input but it shows some erroe message. can anyone tell me the right coding for this one.urgent please...

Use a datetime.timedelta instance to represent the difference between two dates

yA, mA, dA = 1969,7, 21
yB, mB, dB = 2013, 12, 22

import datetime as dt

dateA = dt.date(yA, mA, dA)
dateB = dt.date(yB, mB, dB)
diff = dateB - dateA # a timedelta object
print ("diff is {0} days. (could be negative)".format(diff.days))
print ("and {0} seconds. (nonnegative, less than one day)".format(diff.seconds))
print ("and {0} microseconds. (nonnegative, less than one second)".format(diff.microseconds))

""" my output -->
diff is 16225 days. (could be negative)
and 0 seconds. (nonnegative, less than one day)
and 0 microseconds. (nonnegative, less than one second)
"""
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.