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

DateDiff in hours and minutes

Status
Not open for further replies.

angel7170

Programmer
Mar 12, 2009
15
0
0
US
Hello,

I want to find the difference between two dates in hours and minutes.
Reported Date: 1/7/2009 3:10:13 PM
Resolved Date: 1/7/2009 3:40:50 PM

I used the below formula
DateDiff ("h", {HPD_Help_Desk.Reported_Date}, {HPD_Help_Desk.Last_Resolved_Date})

It returns 0.00
I want the output as 0:30 and also in a number value so that I do an average of total time.
Please assist. Thank you so much





 
I want the output as 0:30 and also in a number value so that I do an average of total time.

Surely then you are looking for the datediff in minutes and not hours? (Of which the correct answer is that there are zero in the example above).

DateDiff ("m", {HPD_Help_Desk.Reported_Date}, {HPD_Help_Desk.Last_Resolved_Date})

The display text can be formatted to hours & mins easily enough if required.

'J

CR8.5 / CRXI - Discovering the impossible
 
Thank You so much for replying!

If I use the formula below to convert into minutes, how can I do an average/total of time in Hours and Minutes. Please assist. Thank you

DateDiff ("n", {HPD_Help_Desk.Reported_Date}, {HPD_Help_Desk.Last_Resolved_Date})


 
As IanWaterman posted previously - For display purposes:

//{@Time}

numbervar hours;
numbervar mins;

hours:=Int({minutes}/60);
mins:= remainder({minutes},60);

totext(hours, 0, "")& ":" & totext(mins, "00",0,"")

'J

CR8.5 / CRXI - Discovering the impossible
 
Thanks again!

It works now. But it is in String format, so I couldn't do a sum/average.
How can I do that?

 
Perform any calculation on the numbers prior to conversion to a more readable format. (The resulting average could also be presented in the more readable format too if required).

'J

CR8.5 / CRXI - Discovering the impossible
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top