date & time difference calculation
Joe Boyle
joeboyle_adt@hotmail.com
Wed, 19 May 2004 11:56:35 +0100
<html><div style='background-color:'><DIV class=RTE>
<P>Hi again,</P>
<P>I don't think that I have seen any code that is taking care of leap years.</P>
<P>I reckon that you will have to loop through the years in the date range and test for YYYY0229 as the result from the lastday function, and for each occurrence subtract 1 from the days component.</P>
<P>I am assuming that the number of days is being calculated using 'mod (numofdays,365)', and then the day count for any remaining whole months are subtracted.</P>
<P>I hav'nt offered any specific code coz' I think its going to get nasty ;-)<BR></P></DIV>
<DIV></DIV>>From: Chris Sharman <chris.sharman@ccagroup.co.uk>
<DIV></DIV>>CC: powerh-l@lists.sowder.com
<DIV></DIV>>Subject: Re: date & time difference calculation
<DIV></DIV>>Date: Tue, 18 May 2004 14:11:07 +0100
<DIV></DIV>>
<DIV></DIV>>Lorry Litman wrote:
<DIV></DIV>>
<DIV></DIV>>>Thank-you Chris, I'll give it a try.
<DIV></DIV>>>
<DIV></DIV>>>How do I turn the days into years, months, & days?
<DIV></DIV>>>
<DIV></DIV>>>As an example
<DIV></DIV>>> difference between 30-dec-2004-10:06 and 11-oct-2003-10:30
<DIV></DIV>>> results in 4452336 (445 days, 23 hours, 36 minutes)
<DIV></DIV>>> I need the result as 0102192336 (1 year, 2 months, 19 days, 23
<DIV></DIV>>>hours, 36
<DIV></DIV>>>minutes)
<DIV></DIV>>>
<DIV></DIV>>>Any suggestions?
<DIV></DIV>>>Maybe there are different powerhouse functions I can/should use.
<DIV></DIV>>
<DIV></DIV>>It's all horribly messy, & I don't think PH can help much - it's
<DIV></DIV>>just arithmetic.
<DIV></DIV>>
<DIV></DIV>>def ddays int*9 = absolute(vmsdt1 - vmsdt2)
<DIV></DIV>>; 20041230.42 - 20031011.44 = 10218.98 (19.98 days looks one too
<DIV></DIV>>many?)
<DIV></DIV>>; 20050130.42 - 20031111.44 = 19018.98 (need same answer !)
<DIV></DIV>>def iyear int*2 = ddays * 0.0001 ; 1
<DIV></DIV>>def imons int*2 = mod(ddays * 0.01 - iyear * 100,88) ; 2
<DIV></DIV>>def idays int*2 = mod(ddays,100) ; 18
<DIV></DIV>>
<DIV></DIV>>I suppose you could get the hours & minutes out of this too.
<DIV></DIV>>
<DIV></DIV>>Chris
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>-----------------------------------------------------------------------
<DIV></DIV>>
<DIV></DIV>>Any views expressed in this message are those of the sender and not
<DIV></DIV>>necessarily those of CCA Group. The unauthorized use, disclosure,
<DIV></DIV>>copying or alteration of this message is forbidden. The contents of
<DIV></DIV>>this message may be confidential and/or privileged, copyright CCA
<DIV></DIV>>Group
<DIV></DIV>>and are intended solely for the use of the individual or entity to
<DIV></DIV>>whom
<DIV></DIV>>they are addressed. Whilst this message has been scanned, CCA Group
<DIV></DIV>>cannot guarantee that it is virus free or compatible with your
<DIV></DIV>>systems
<DIV></DIV>>and accepts no responsibility for any loss or damage arising from
<DIV></DIV>>its
<DIV></DIV>>use. The recipient is advised to run their own anti-virus software.
<DIV></DIV>>If
<DIV></DIV>>you receive this message in error please contact
<DIV></DIV>>postmaster@ccagroup.co.uk immediately, destroy any copies and delete
<DIV></DIV>>it
<DIV></DIV>>from your computer systems.
<DIV></DIV>>= = = = = = = = = = = = = = = = = = = = = = = = = = = =
<DIV></DIV>>Mailing list: powerh-l@lists.sowder.com
<DIV></DIV>>Subscribe: "subscribe" in message body to
<DIV></DIV>>powerh-l-request@lists.sowder.com
<DIV></DIV>>Unsubscribe: "unsubscribe <password>" in message body to
<DIV></DIV>>powerh-l-request@lists.sowder.com
<DIV></DIV>>http://lists.sowder.com/mailman/listinfo/powerh-l
<DIV></DIV>>This list is closed, thus to post to the list you must be a
<DIV></DIV>>subscriber.
<DIV></DIV></div></html>