Adding Time in a Numeric World
Latimer, Richard
richard.latimer@airways.co.nz
Tue, 4 Jul 2000 08:13:10 +1200
Further to Ole's reply,
date time arithmetic is hard work whatever language you use!
We do lots of it in our applications and while Ole's reply works well we
prefer to remain doing arithmetic on numberic fields as number to string and
substring operations are very inefficient on the AS/400 platform we are
using. And we are stuck on PowerHouse v 6.07 with no expectation of further
progress :-)
We use several variations of the attached snippet which converts a num*4
field into minutes:
((FLOOR(t_tme_ata/100)*60) &
+ (t_tme_ata - (FLOOR(t_tme_ata/100)*100)))
if you want to get down to seconds it's a bit longer :
TEMPORARY t_atbsec NUM*5
ITEM t_atbsec =
&
((FLOOR(TME_ATB OF fpl_cancellation_ed/10000)) * 3600) + &
(((FLOOR(TME_ATB OF fpl_cancellation_ed/100)) -
&
((FLOOR(TME_ATB OF fpl_cancellation_ed/10000)) * 100)) * 60) &
+ (TME_ATB OF fpl_cancellation_ed -
&
((FLOOR(TME_ATB OF fpl_cancellation_ed/100)) * 100))
Regards
Richard
> Original Message-----
> From: Ole Hansen, ScanConsult [SMTP:oh@scanconsult.dk]
> Sent: Tuesday, July 04, 2000 6:17 AM
> To: Joseph Rosenblatt; powerh-l
> Subject: Sv: Adding Time in a Numeric World
>
> Hi Joseph,
>
> FWIW, here is what I did in a similar situation years back :
>
> Convert you time-values to minutes :
>
> DEFINE TOTMINS INT*4 = 60 * NCONVERT(ASCII(time_value,4)[1:2] + &
> NCONVERT(ASCII(time_value,4)[3:2]
>
> Do your subtotals to a subfile, and report from the subfile, converting
> back to hours and minutes :
>
> DEFINE HOURS INT*4 = ROUND(TOTMINS/60,0)
> DEFINE MINS INT*2 = MOD(TOTMINS,60)
>
> HTH
>
> /Ole Hansen
>
>
**********************************************************************
The information contained in this email message is intended only for the addressee. If you are not the intended recipient you must not use, store, disclose, copy or distribute this message or the information in it. If you have received this message in error please notify us immediately by reply email or by telephone +64-4-471-1888.
Any views expressed in this email are those of the individual sender and may not necessarily reflect the views of Airways Corporation of New Zealand.
You must scan this email and any attached files for viruses. Airways Corporation of New Zealand accepts no liability for any loss, damage or consequence, whether caused by our own negligence or not, resulting directly or indirectly from the use of any attached files.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
This list is closed, thus to post to the list, you must be a subscriber.