Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating Average of the times and then do difference 3

Status
Not open for further replies.
Apr 18, 2007
209
US
I have a similar problem like yesterday but instead of minimun I have to do average.
What I am thinking is convert the time to number of seconds and do average?. Any good ideas?, or how to convert the time to a number to I can do average of time?. Is this a good idea? or any better solution for this?.
Thanks a lot.
Toby
 
I did the difference in seconds
(DateDiff ("s",{date1},{date2} ))

I have it in secons Now I can do a average. But how can i convert the final average value to proper time hh:mm:ss?
Any idea friends?

Thanks for the time
T.
 
How is time calculated.

If difference is between two datetime fields use datediff to convert to seconds.

@Time
DateDiff ("s", datetime1, datetime2)

YOu can then perform an average on formula.

Or create a formula perform the average and then convert seconds back to a time.

Ian
 
Yes I calculated the differecne already in secons and did an average. But who to conevert that average into time again? any ideas?. Thanks for your respone.
Tobe.
 
@TimeDisp

whileprintingrecords;

local numbervar hour:= int(@time/3600);

local numbervar min:= int((remainder(@time,3600))/60);

local numbervar sec:= remainder(remainder(@time,3600),60);

totext(hour,0)&":"totext(min,0)&":"totext(sec,0)

Where @Time is your date diff formula.

Ian


 
Sorry forgot you wanted an average

change formula to

@TimeDisp

whileprintingrecords;
local numbervar avtime:= average(@time,groupfield);

local numbervar hour:= int(avtime/3600);

local numbervar min:= int((remainder(avtime,3600))/60);

local numbervar sec:= remainder(remainder(avtime,3600),60);

totext(hour,0)&":"totext(min,0)&":"totext(sec,0)

Where @Time is your date diff formula.

Ian

 
Thanks a ton, formula works ony thing is i added local string var to the last part of the formula.

Thanks so much for your time.
Tob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top