Post
by Alois Fuchs » 23 Feb 2006, 19:34
Posted by: Alois Fuchs
hi paul,
you can simply add (or also subtract) days/hours/minutes/seconds, calculated
as a (fractional) part of a 24 hour's day, to a date - like this:
Date/Time: dDate1
Date/Time: dDate2
Number: nDateDiff
! set dDate1 to a certain value:
Set dDate1 = 2006-02-23
! to add, for example, 1 d 12 h 25 m 32 s, convert all to seconds:
Set nDateDiff = ( 1*24*60*60 + 12*60*60 + 25*60 + 32 ) / ( 24*60*60 )
Set dDate2 = dDate1 + nDateDiff ! it works properly, no error
"assignment of different types" occurs!
Call SalMessageBox( SalFmtFormatDateTime( dDate2, 'yyyy-MM-dd hhhh:mm:ss' ),
'new date/time', MB_Ok )
! dDate2 shows 2006-02-24 12:25:32
! add another 45 m 10 s:
Set nDateDiff = ( 45*60 + 10 ) / ( 24*60*60 )
Set dDate2 = dDate2 + nDateDiff
Call SalMessageBox( SalFmtFormatDateTime( dDate2, 'yyyy-MM-dd hhhh:mm:ss ),
'new date/time', MB_Ok )
! dDate2 shows 2006-02-24 13:10:42
alois