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