Converting this into hh:mm:ss was not as straightforward as I would think due to inconsistent typecasting of variables and odd handing of the ROUND command.
The code I ended up with is below, which gets the TIME OF DAY of the first entry in the case history
Code: Select all
timestamp = FETCH( "CONTENT" , "History" , "created_time" , "FOR FIRST History NO-LOCK WHERE History.case_no = '" + {case.key} + "'" )
#MESSAGE( "timestamp: " , timestamp )
#A=number of hours
A = timestamp / 3600
#B = minutes as fraction of hours
B = A MOD 1
#typecaset B as decimal
PUT( B , {temp decimal.Value} )
#C = whole hours
C = A - {temp decimal.Value}
myhours = C
#MESSAGE( "myhours " , myhours )
#D = remainder as minutes
D = B * 60
#E = seconds as fraction of minutes
E = D MOD 1
#typecast
PUT( E , {temp decimal.Value} )
#whole minutes
F = D - {temp decimal.Value}
mymins = F
#MESSAGE( "mymins " , mymins )
#G = remainder as seconds
G = E * 60
#decimal seconds
H = G MOD 1
#typecast
PUT( H , {temp decimal.Value} )
#whole seconds
I = G - {temp decimal.Value}
myseconds = I
#MESSAGE ("myseconds ",myseconds)
#construct time in H:M:S
#TODO - pad with zeros
mytime = TEXT( myhours ) + ":" + TEXT( mymins ) + ":" + TEXT( myseconds )
MESSAGE( mytime )
result = mytime
Error in ROUND command:
Code: Select all
#11:54:12 = 42852 seconds
timestamp = 42852
#convert into decimal hours - should be 11.9033
A = timestamp / 3600
#round down to whole hours - shoud be 11
B = ROUND( A , 0 , DOWN )
#result should be 11, but is actually 12!
MESSAGE( B )