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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate Average For Time

Status
Not open for further replies.

yazanmom

IS-IT--Management
Dec 19, 2012
2
JO
I'm new in crystal reports and need advice please,

I have report Where it shows:

Open Time, Closed Time, Duration

I need a way to calculate the average of the duration

*Duration shows in report in this way
0 Day 01 h 53 min
1 Day 02 h 45 min
5 Day 05 h 20 min

Any Help Please?
 
Provided data is always in same format and days stay in single digits you can convert all to mins

@Mins

(tonumber(left(duration, 1))*1440) + (tonumber(mid(duration, 7,2))*60) + tonumber(mid(duration, 12,2))

You can then use a normal average summary of this formula.

Ian
 
Thanks Ian
Its worked fine and view the average with minute format and it's acceptable

Thanks again.
 
You can convert your average back if you want, place this in your report footer

@Avg
numberVar dur := average(@mins)
numberVar hrs;
numberVar min;
stringVar result;

days := Truncate(dur/1440);
hrs := Truncate(Remainder(dur,1440)/60);
min := Remainder(Remainder(Remainder(dur,1440),60),60);


result := totext(days, "0") + " d, " + totext(hrs, "0") + " h, " + totext(min,"0") + " m";

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top