date & time difference calculation

Chris Sharman chris.sharman@ccagroup.co.uk
Tue, 18 May 2004 14:11:07 +0100


Lorry Litman wrote:

> Thank-you Chris, I'll give it a try.
> 
> How do I turn the days into years, months, & days?
> 
> As an example
>  difference between 30-dec-2004-10:06 and 11-oct-2003-10:30
>  results in 4452336 (445 days, 23 hours, 36 minutes)
>  I need the result as 0102192336 (1 year, 2 months, 19 days, 23 hours, 36
> minutes)
> 
> Any suggestions?
> Maybe there are different powerhouse functions I can/should use.

It's all horribly messy, & I don't think PH can help much - it's just 
arithmetic.

def ddays int*9 = absolute(vmsdt1 - vmsdt2)
; 20041230.42 - 20031011.44 = 10218.98 (19.98 days looks one too many?)
; 20050130.42 - 20031111.44 = 19018.98 (need same answer !)
def iyear int*2 = ddays * 0.0001 ; 1
def imons int*2 = mod(ddays * 0.01 - iyear * 100,88) ; 2
def idays int*2 = mod(ddays,100) ; 18

I suppose you could get the hours & minutes out of this too.

Chris


-----------------------------------------------------------------------

Any views expressed in this message are those of the sender and not
necessarily those of CCA Group.  The unauthorized use, disclosure,
copying or alteration of this message is forbidden.  The contents of
this message may be confidential and/or privileged, copyright CCA Group
and are intended solely for the use of the individual or entity to whom
they are addressed.  Whilst this message has been scanned, CCA Group
cannot guarantee that it is virus free or compatible with your systems
and accepts no responsibility for any loss or damage arising from its
use. The recipient is advised to run their own anti-virus software. If
you receive this message in error please contact
postmaster@ccagroup.co.uk immediately, destroy any copies and delete it
from your computer systems.