Datetime & Duration

Guys, Im in a lil fix here, im sure will find a solution here…on the boards…heres the problem Var DT1 Type Datetime Var DT2 Type Datetime Var Dur Type Duration D1:=01/07/04 08:30:00 D2:=01/07/04 17:00:00 Dur := D2 - D1; which is ‘8 hours 30 minutes’ now I want to format the value of Dur to Hours:Mins i.e. i want to display 8:30 instead of ‘8 hours 30 minutes’, I tried using the format property, but it gives an error with regards to the stx file… also wanted to know if there is way to total the duration in a report, like a Group Total. all suggestions welcome… thanx a ton Vishal

Hi Vishal, Seems like a bug in the compiler to currectly identify the DateTime functionality, Its the same even in v4.0, but you can use the CurrReport.CREATETOTALS to create the total for the duration. It works the same way as any other variable total. Naveen Jain

Yeah, a little experimenting shows that FORMAT hasn’t caught up with Durations. The following attempts throw the error ‘There are errors in the text conversion (text no. 144-2000 does not exist in the .stx file). Internal error 47-1.’ FORMAT(Dur,0,'<Standard Format,3>'); FORMAT(Dur,0,'<Hour,2>:<Minute,2>'); You can get result you want, however, by treating a Duration as a BigInteger that contains milliseconds. Continuing your example: bigInt := Dur; intHours := bigInt DIV (60*60*1000); intMin := (bigInt MOD (60*60*1000)) DIV (60*1000); MESSAGE('Duration: %1:%2.', FORMAT(intHours,0,'<Integer,2><Filler,0>'), FORMAT(intMin,0,'<Integer,2><Filler,0>')); Finally, since Durations are just milliseconds, I don’t see why they couldn’t be summed in a report just like any other numeric field.

Hi Naveen / Fritz, Thanx so much guys for your replies, Fritz I tried the solution you gave a test env. and it works fine. Cheers