Number of months between 2 dates
Findlay, Colin
colin.findlay@fmglobal.com
Fri, 5 Sep 2003 08:43:40 +0100
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
==
Colin
Ps - I bet it doesn't work for dates in the same year, but it'd be easy
enough to determine whether they were in the same year first and use an even
simpler algorithm for those cases...
-----Original Message-----
From: Edis, Robert [mailto:REdis@blistex.com]
Sent: 04 September 2003 18:22
To: Powerh-L (E-mail)
Subject: RE: Number of months between 2 dates
What type of months? I.e. what calendar, Gregorian (12 months of varying
length), lunar (12 months of 30 days each, Baha'i (19 months of 19 days each
plus 4 or 5 top-up days), other?
The former type would be VERY difficult to do in an algorithm and you
probably need to create one or more lookup tables. Calendars where the
months have consistent lengths are easy.
Blue
-----Original Message-----
From: Terry Pickering [mailto:pickering@4j.lane.edu]
Sent: Thursday, September 04, 2003 11:17 AM
To: powerh-l@lists.swau.edu
Subject: Number of months between 2 dates
Does anyone have an algorithm around that would compute the number of full
MONTHS between two dates? Example is the number of months between 7/12/1968
and 10/8/2002.
Thanks!
____________________________
Terry Pickering
= = = = = = = = = = = = = = = = = = = = = = = = = = = =
Mailing list: powerh-l@lists.swau.edu
Subscribe: "subscribe" in message body to powerh-l-request@lists.swau.edu
Unsubscribe: "unsubscribe <password>" in message body to
powerh-l-request@lists.swau.edu
http://lists.swau.edu/mailman/listinfo/powerh-l
This list is closed, thus to post to the list you must be a subscriber.
= = = = = = = = = = = = = = = = = = = = = = = = = = = =
Mailing list: powerh-l@lists.swau.edu
Subscribe: "subscribe" in message body to powerh-l-request@lists.swau.edu
Unsubscribe: "unsubscribe <password>" in message body to
powerh-l-request@lists.swau.edu
http://lists.swau.edu/mailman/listinfo/powerh-l
This list is closed, thus to post to the list you must be a subscriber.