Number of months between 2 dates
John Hunter
jthunter@nbnet.nb.ca
Fri, 5 Sep 2003 08:59:31 -0300
If it doesn't work for dates in the same year then
add a year to the date1:
def date1 date = 20020810 + 10000
and then subtract
12 months from the final tally:
def number_months_between = &
(12 * (number_full_years_between)) + &
number_months_left_2 + &
number_months_gone_1 - 12
-John
-----Original Message-----
From: powerh-l-admin@cube.swau.edu
[mailto:powerh-l-admin@cube.swau.edu]On Behalf Of Findlay, Colin
Sent: September 5, 2003 4:44 AM
To: Powerh-L (E-mail)
Subject: RE: Number of months between 2 dates
Well, it's only a knee-jerk reaction and I haven't tested it out on any
other dates, but my quick fag-packet calculation of the number of months
starting at 1st January 1969 (the first full month after the earlier date)
and 31st July 2002 (the last full month before the later date) gives the
number 403. Which is also given by this code:
def date1 date = 20020810
def date2 date = 19681207
def date1_month = nconvert(ascii(date1,8)[5:2])
def date2_month = nconvert(ascii(date2,8)[5:2])
def date1_year = nconvert(ascii(date1,8)[1:4])
def date2_year = nconvert(ascii(date2,8)[1:4])
def number_full_years_between = (date1_year - (date2_year + 1))
def number_months_gone_1 = date1_month - 1
def number_months_left_2 = 12 - date2_month
def number_months_between = &
(12 * (number_full_years_between)) + &
number_months_left_2 + &
number_months_gone_1
rep number_months_between
Go