how can I check the difference between two dates using the datetime modules? (or any other module that would do the same thing).
I want to read a date from a file (which was written in the same format as the datetime module uses) and then calculate the difference in days between that date and today.
mahela007
6
Posting Whiz in Training
Recommended Answers
Jump to Post>>> import datetime >>> dir(datetime) ['MAXYEAR', 'MINYEAR', '__doc__', '__name__', '__package__', 'date', 'datetime', 'datetime_CAPI', 'time', 'timedelta', 'tzinfo'] >>> #Use method date and timedelta >>> print datetime.date.today() 2010-01-11 >>> >>> #Find now days since 1 Jan 1901 >>> one_day = datetime.timedelta(days=1) >>> long_time_ago = datetime.date(1901, 1, 01) >>> print …
All 5 Replies
snippsat
661
Master Poster
mahela007
6
Posting Whiz in Training
Stefano Mtangoo
455
Senior Poster
mahela007
6
Posting Whiz in Training
Stefano Mtangoo
455
Senior Poster
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.