Subtracting Time Elements

M

MEM

Hello!
My question is, I would like to track the time spent on
various projects. Some time increments may be very small
others may be larger. I would line to subtract the start
time and end time and store these time increements for
printing as well as a total of time per day, per month.

Example: Start time = 10:20 End time = 10:32. What syntax
do I need to subtract these values save the time
difference for each project, and sum the daily, monthly
totals using a query and print a monthly report including
the time values and totals.

Thank You in advance for your Help!
 
J

John Vinson

Example: Start time = 10:20 End time = 10:32. What syntax
do I need to subtract these values

DateDiff("n", [Start Time], [End Time])

will calculate the difference as an integer count of minutes - i.e. if
[Start Time] is 11:00am yesterday and [End Time] is 11:00am today, it
will return 1440 minutes.
save the time
difference for each project, and sum the daily, monthly
totals using a query and print a monthly report including
the time values and totals.

Don't store it; instead, calculated as needed by putting the DateDiff
expression in a vacant Field cell in a query, and base your Report on
the query. You can sum the time values in the Report Footer or in the
footer of a sorting and grouping block on the Report.
 
G

Guest

Thanks John,

The DateDiff works well except when the time is:

Start Time = 12:58 End Time = 1:04 the DateDiff result is
a -714. Is there a way to format this to give me the
correct result?

Thanks Again for your help

-----Original Message-----
Example: Start time = 10:20 End time = 10:32. What syntax
do I need to subtract these values

DateDiff("n", [Start Time], [End Time])

will calculate the difference as an integer count of minutes - i.e. if
[Start Time] is 11:00am yesterday and [End Time] is 11:00am today, it
will return 1440 minutes.
save the time
difference for each project, and sum the daily, monthly
totals using a query and print a monthly report including
the time values and totals.

Don't store it; instead, calculated as needed by putting the DateDiff
expression in a vacant Field cell in a query, and base your Report on
the query. You can sum the time values in the Report Footer or in the
footer of a sorting and grouping block on the Report.


.
 
J

John Vinson

Thanks John,

The DateDiff works well except when the time is:

Start Time = 12:58 End Time = 1:04 the DateDiff result is
a -714. Is there a way to format this to give me the
correct result?

That is the correct result. All Date/Time values are stored as double
float numbers, a count of days and fractions of a day since midnight,
December 30, 1899. 12:58PM was in fact 714 minutes LATER than 1:04AM
on that date.

I would suggest that if your times will span midnight, that you store
the date AND the time in the same field - DateDiff("n", #02/21/2004
12:58#, #02/22/2004 01:04#) will give you a positive value.

Alternatively (and IMO undesirably) you can add 1440 minutes if the
end time is before the start time:

DateDiff("n", [Start Time], [End Time]) + IIF([Start Time] > [End
Time], 1440, 0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top