Hi,
Can anyone please let me know how to find the average of time field in Natural?My requirement is to find the Average time between the last 2 updates of a record. I could find the difference in the time, but Cld nt find the average between the two.
How about taking half the difference and adding it to the earlier time???
for example
DEFINE DATA LOCAL
1 #T1 (T)
1 #T2 (T)
1 #T3 (T)
END-DEFINE
*
COMPUTE #T3 = #T1 + .5 * (#T2 - #T1)
END
steve
How about taking half the difference and adding it to the earlier time???
for example
DEFINE DATA LOCAL
1 #T1 (T)
1 #T2 (T)
1 #T3 (T)
END-DEFINE
*
COMPUTE #T3 = #T1 + .5 * (#T2 - #T1)
END
steve
Thanks Steve 4 ur reply.
My requirement is to find the average time for all the records in the Adabas file.
In that case how to compute the avearge time?
The problem is the Time field is declared a numeric in the Adabas file & I want the final value in Time format.
I am able to do it only after converting the entire time to seconds format.
is there any other easier way 2 do the same?
Your problem is not knowing what Time Format really is; namely a P13 variable which contains the number of tenths of seconds since Day 1 Year Zero.
Run the following program
DEFINE DATA LOCAL
1 #T1 (T)
1 REDEFINE #T1
2 #P1 (P13)
1 #T2 (T)
1 REDEFINE #T2
2 #P2 (P13)
1 #T3 (T)
1 REDEFINE #T3
2 #P3 (P13)
END-DEFINE
*
MOVE *TIMX TO #T1 #T2
COMPUTE #P3 = .5 * (#P1 + #P2)
WRITE #T3 #T1
END
Just REDEFINE your time variables as P13 variables and do the arithmetic. No conversion between T and numeric is required; it is already numeric.
By the way, the same is true for Date variables; except they are P7.
steve