Dates - Do I need to write my own function?

  • Thread starter Thread starter LAS
  • Start date Start date
L

LAS

I have start and end times in tables. I want to write a report that shows
the elapsed time in hours and minutes. I've got the elapsed time in minutes
(currently a string, but it seems as if I could use an integer as well). Is
there anything already written that will convert the minutes (using totals,
the minutes could be in the hundreds or thousands), to hours and minutes?

tia
las
 
I have start and end times in tables. I want to write a report that shows
the elapsed time in hours and minutes. I've got the elapsed time in minutes
(currently a string, but it seems as if I could use an integer as well). Is
there anything already written that will convert the minutes (using totals,
the minutes could be in the hundreds or thousands), to hours and minutes?

tia
las

Sure:

DateDiff("h", [start time], [end time]) & ":" & Format(DateDiff("n", [start
time], [end time]) \ 60), "00")

--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
I don't think that will return valid data.

Try the following revision of John's expression (all one line) instead.
DateDiff("n", starttime, endtime)\60 & ":" & Format(DateDiff("n", starttime,
endtime) mod 60, "00")

StartTime = #13:50:00#
EndTime = #14:01:00#
?DateDiff("h", starttime, endtime) & ":" & Format(DateDiff("n", starttime,
endtime) mod 60, "00")
returns 1:00

The revised expression returns 0:11

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
I have start and end times in tables. I want to write a report that shows
the elapsed time in hours and minutes. I've got the elapsed time in minutes
(currently a string, but it seems as if I could use an integer as well). Is
there anything already written that will convert the minutes (using totals,
the minutes could be in the hundreds or thousands), to hours and minutes?

tia
las

Sure:

DateDiff("h", [start time], [end time]) & ":" & Format(DateDiff("n", [start
time], [end time]) \ 60), "00")
 
I don't think that will return valid data.

Try the following revision of John's expression (all one line) instead.
DateDiff("n", starttime, endtime)\60 & ":" & Format(DateDiff("n", starttime,
endtime) mod 60, "00")

Thanks, John - had a brainfade there, your expression is of course the correct
one.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
Thanks for following up here. I was trying to fix it myself, but it was
going slow.

John Spencer said:
I don't think that will return valid data.

Try the following revision of John's expression (all one line) instead.
DateDiff("n", starttime, endtime)\60 & ":" & Format(DateDiff("n",
starttime, endtime) mod 60, "00")

StartTime = #13:50:00#
EndTime = #14:01:00#
?DateDiff("h", starttime, endtime) & ":" & Format(DateDiff("n", starttime,
endtime) mod 60, "00")
returns 1:00

The revised expression returns 0:11

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
I have start and end times in tables. I want to write a report that
shows the elapsed time in hours and minutes. I've got the elapsed time
in minutes (currently a string, but it seems as if I could use an
integer as well). Is there anything already written that will convert
the minutes (using totals, the minutes could be in the hundreds or
thousands), to hours and minutes?

tia
las

Sure:

DateDiff("h", [start time], [end time]) & ":" & Format(DateDiff("n",
[start
time], [end time]) \ 60), "00")
 
Back
Top