Calculate time

H

Harmannus

Hallo,

I have a form with a start and end time per employee by day; I calculate the
working time with:

WorkingHours: Format([StartTime]-1-[EndTime];"Short Time")

How can i total the WorkingHours with the above formula? With sum i get a
data type mismatch...

E.g.
Kelly starts a 9 and works till 12 on 17-10-2003; Working hours 3
Kelly starts a 9 and works till 12 on 18-10-2003; Working hours 3
Total by the end of the month 6

Thanx for tips!


Regards,

Harmannus
 
A

Allen Browne

The Format() function returns a string value which can't be summed.
You need a numeric value. This will give you the result in hours and
fractions of an hour, e.g. 3.5 is three and a half hours:
WorkingHours: DateDiff("n", [StartTime], [EndTime]) / 60
 
S

Steve Schapel

Harmannus,

Easiest way is to use DateDiff...
WorkingHours: DateDiff("h";[Start Time];[End Time])
which will give you a result you can sum.

However, the expression you have used so far would imply that the time
period can possibly span across midnight.

If so, here are a couple of ideas that should work for you:

WorkingHours: ([End Time]-[Start Time]-([Start Time]>[End Time]))*24

WorkingHours: Format([Start Time]-1-[End Time];"h")+Format([Start
Time]-1-[End Time];"nn")/60

- Steve Schapel, Microsoft Access MVP
 
H

Harmannus

Hallo,

Thanx for the tips! I will implement them! Greatly appreciate te help!


Regards,

Harmannus

--
Met vriendelijke groet,

Harmannus
Steve Schapel said:
Harmannus,

Easiest way is to use DateDiff...
WorkingHours: DateDiff("h";[Start Time];[End Time])
which will give you a result you can sum.

However, the expression you have used so far would imply that the time
period can possibly span across midnight.

If so, here are a couple of ideas that should work for you:

WorkingHours: ([End Time]-[Start Time]-([Start Time]>[End Time]))*24

WorkingHours: Format([Start Time]-1-[End Time];"h")+Format([Start
Time]-1-[End Time];"nn")/60

- Steve Schapel, Microsoft Access MVP


Hallo,

I have a form with a start and end time per employee by day; I calculate the
working time with:

WorkingHours: Format([StartTime]-1-[EndTime];"Short Time")

How can i total the WorkingHours with the above formula? With sum i get a
data type mismatch...

E.g.
Kelly starts a 9 and works till 12 on 17-10-2003; Working hours 3
Kelly starts a 9 and works till 12 on 18-10-2003; Working hours 3
Total by the end of the month 6

Thanx for tips!


Regards,

Harmannus
 

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