DateDiff in "short time" format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to get time in a "short time" format from a DateDiff formula?

example:
Start End DIFFERENCE
5:00AM 6:30AM 1:30
 
Get the different in minutes, and then devide by 60

datediff("n",StartTime, EndTime)/60
 
OK, OK
Try this, mybe there is a better way, but I can't think of one

=datediff("h","5:00AM", "6:30AM") & ":" & datediff("n","5:00AM",
"6:30AM") - datediff("h","5:00AM", "6:30AM")*60
 
Since Time is stored as a fraction of a day, you can take advantage of the
fact that there are 1440 minutes in a day and use:

=Format(DateDiff("n", StartTime, EndTime)/1440, "Short Time")

?Format(DateDiff("n", #05:00:00#, #06:30:00#)/1440, "Short Time")
01:30

Of course, this won't work for time differences that are greater than 24
hours.
 
Is there a way to get time in a "short time" format from a DateDiff
formula?

If you get the minutes, you can format it yourself:

minutes = datediff("n", Time2, Time1)

newOutput = Format(minutes \ 60, "0") & ":" & _
Format(minutes mod 60)


Hope that helps

Tim F
 
Thanks.

Douglas J Steele said:
Since Time is stored as a fraction of a day, you can take advantage of the
fact that there are 1440 minutes in a day and use:

=Format(DateDiff("n", StartTime, EndTime)/1440, "Short Time")

?Format(DateDiff("n", #05:00:00#, #06:30:00#)/1440, "Short Time")
01:30

Of course, this won't work for time differences that are greater than 24
hours.
 
Back
Top