Date arithmetic in MFC greater than a month
Posted on 2001-06-06
Does anyone know how to conduct date arithmetic in MFC with differences greater than a month or a year. The CDateTimeSpan object is useless in this context because the absolute amount of time in the span is dependent upon what the starting date is. For example, adding 1 month to February 1st adds 28 days, while adding 1 month to March 1st adds 31 days, of course.
What I want to do is get the date of 1 year ago today. I tried subtracting 1 from the year, and otherwise loading the current date into a COleDateTime object. That won't work on February 29th, the resultant date is invalid.
I'm sure there's a simple way or something I haven't thought of.
Thanks in advance.