Re: Number of months...
Posted in 1997
Michael Hoffman wrote: > > Ok, this may be the simplest question I've ever posted, but, then agin, it may > be as tough as we've found. > > What we have are 2 dates and 2 datetimes. We need to find the number of months Try someting like this: Y0 = Year(Date2) - Year(date1) Ym = Y0 *12 M0 = Month(date1) - Month(date2) Mt = Ym - M0 Or to put it into one equation: #Months =[Year(date2) - Year(date1)]*12 - [Month(date1) - Month(date2)] This should work. I tried this test case: Date 1 = 06/01/95 Date 2 = 08/22/96 -- We don't care about the dates #Months = 12 - ( -2) = 14 months Then try the inverse Date 1 = 08/22/95 Date 2 = 06/01/96 #Months = 12 - (2) = 10 Months. Just a simple tip from your Uncle Mike. -- #include <std_disclaimer.h> /* Mike Segel (MS385) */ #include <No_Spam.h> #ifdef OFFENDED_BY_CONTENT The author takes no responsibility for this post. Any resemblence to a coherent rational thought is purely coincidence. -The Management. #endif