Using DateDiff to Calculate Time Worked

A

Annette

When I use DateDiff to calculate the time worked in an
expression, I get only the Number of hours, rounded to the
nearest hour.

Example: TimeWorked: DateDiff("h",[StartTime],[EndTime])

If I enter the syntax for hours and minutes, I get
an "invalid procedure call" error.

Example: TimeWorked: DateDiff("hn",[StartTime],[EndTime])

How can I calculate the hours and minutes worked in a
query?

Thanks for any help.
 
S

Steve Schapel

Annette,

You'll have to get the difference in minutes and then calculate to
hours from there. For example...
TimeWorked: DateDiff("n",[StartTime],[EndTime])\60 & ":" &
DateDiff("n",[StartTime],[EndTime]) Mod 60

- Steve Schapel, Microsoft Access MVP
 

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