R
Rose
Is there away to minus time in hours beyond [CheckOut]-[CheckIn]
KARL DEWEY said:What about ---
DateAdd("h",[Your value], [YourFieldName])
h - hours
d - days
n - minutes
w - weeks
m - months
q - quarters
yyyy - years
--
KARL DEWEY
Build a little - Test a little
Rose said:Is there away to minus time in hours beyond [CheckOut]-[CheckIn]
Rose said:How do you get the minutes to show as well. For instant 2 and a half hours.
--
Rose
KARL DEWEY said:What about ---
DateAdd("h",[Your value], [YourFieldName])
h - hours
d - days
n - minutes
w - weeks
m - months
q - quarters
yyyy - years
--
KARL DEWEY
Build a little - Test a little
Rose said:Is there away to minus time in hours beyond [CheckOut]-[CheckIn]
John Spencer said:That could lead to erroneous results since DateDiff counts changes in
the increment so going from any time in an hour to any time in the next
hour will get a result of 1 even though it is possible that less than a
minute has elapsed. For example,
DateDiff("h",#10:59:59#,#11:00:01#)
will return one not zero.
I would use something like
Stay: "Hours: " & DateDiff("n",[CheckIn],[CheckOut])\60
& " Minutes: " & DateDiff("n",[CheckIn],[CheckOut])) Mod 60
And if the number of minutes was crucial I might go so far as to use
dateDiff seconds and then divide that by 60 to get the minutes and then
use Mod 60 on the result.
If the poster wanted something like
32:40 to represent 32 hours and 40 minutes then we would need to throw
in the format function to ensure leading zeroes for durations such as
32:07 (32 hours 7 minutes)
Stay: DateDiff("n",[CheckIn],[CheckOut])\60
& ":" & Format(DateDiff("n",[CheckIn],[CheckOut])) Mod 60,"00")
'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
KARL said:Try this --
Stay: "Hours: " & DateDiff("h",[CheckIn],[CheckOut]) & " Minutes: " &
((DateDiff("h",[CheckIn],[CheckOut]))*60)-DateDiff("n",[CheckIn],[CheckOut])
Rose said:Hi John,
Your last calculation worked but I am unable to sum the total time by
members. Your first few calculations look good but I recieve an invalid
syntax error You need to enclose your text data in quotes. Do you know
what
I might be doing wrong. Thanks for all your help.
--
Rose
John Spencer said:That could lead to erroneous results since DateDiff counts changes in
the increment so going from any time in an hour to any time in the next
hour will get a result of 1 even though it is possible that less than a
minute has elapsed. For example,
DateDiff("h",#10:59:59#,#11:00:01#)
will return one not zero.
I would use something like
Stay: "Hours: " & DateDiff("n",[CheckIn],[CheckOut])\60
& " Minutes: " & DateDiff("n",[CheckIn],[CheckOut]) Mod 60
And if the number of minutes was crucial I might go so far as to use
dateDiff seconds and then divide that by 60 to get the minutes and then
use Mod 60 on the result.
If the poster wanted something like
32:40 to represent 32 hours and 40 minutes then we would need to throw
in the format function to ensure leading zeroes for durations such as
32:07 (32 hours 7 minutes)
Stay: DateDiff("n",[CheckIn],[CheckOut])\60
& ":" & Format(DateDiff("n",[CheckIn],[CheckOut])) Mod 60,"00")
'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
KARL said:Try this --
Stay: "Hours: " & DateDiff("h",[CheckIn],[CheckOut]) & " Minutes: " &
((DateDiff("h",[CheckIn],[CheckOut]))*60)-DateDiff("n",[CheckIn],[CheckOut])