Newbie: Subtracting Dates

mowestusa justnotworking at mail.com
Thu Dec 5 14:39:44 EST 2002


I've been looking through the information in the ActiveState distrubition of
Python for the answer, but haven't found it yet.

I thought a fun, easy, and useful program to write as a beginner would be a
date program.  I'm not looking to have a nice GUI face on it or anything,
but that could be added as I grow in experience and knowledge.

It seems that programing date addition and subtraction is harder than I
realized.  I'm wondering if Python offers anything to help with this.  I
would also like to know of some web resources that I could read about
programming and working with dates.  Excel and other spread sheets do it all
of the time, so I know that it can be done.  Also I could think of lots of
applications once I understand this basic concept like: a birthday reminder,
bill payment reminder, financial planning once one knows the time frame, and
others.

Basically, I would like to create a program that subtracts Date #1 from Date
#2.  The output would give the total number of "years", "months", and "days"
in between dates.  Like the following example:

Date #1    1/1/1900
Date #2    12/6/2002
Years:    102
Months:  11
Days:        5

If we are talking about antiques and Date #1 was the produced date.  The
piece would be 102 years, 11 months, and 5 days.

Thanks for any direction.

mowestusa






More information about the Python-list mailing list