DateDiff calculation

S

snowball

I am trying to get an efficiency figure calculation from a start time less a
finish time less the sum of personal breaks and m/c breaks.

Start time = Tin
Finish Time = TOut
start -less finish Time = workedT
personal breaks = Pbreak
Machine downtime = M/C break

I have managed to calculate the WorkedT by using the datediff function,
DateDiff("n",[TIn],[TOut])\60 & Format(DateDiff("n",[TIn],[TOut]) Mod
60,"\:00") this is now my workedT,

However i now need to subtract the sum of [Pbreak]+[M/C Break] from my
[worked time] and my answer needs to be in Minutes.

Can anyone help.
 
A

Allen Browne

Try:
DateDiff("n", [Tin], [TOut]) - Nz([Pbreak],0) - Nz([m/c break],0)

This assumes yoru field types are:
- Tin Date/Time
- TOut Date/Time
- Pbreak Number (in minutes)
- m/c break Number (in minutes)

If you must Format the result, do so only at the end of the calculation.
Format() generates a string (text), which may not handle further
calculations the way you expect.
 
S

snowball

Thanks that helped

Allen Browne said:
Try:
DateDiff("n", [Tin], [TOut]) - Nz([Pbreak],0) - Nz([m/c break],0)

This assumes yoru field types are:
- Tin Date/Time
- TOut Date/Time
- Pbreak Number (in minutes)
- m/c break Number (in minutes)

If you must Format the result, do so only at the end of the calculation.
Format() generates a string (text), which may not handle further
calculations the way you expect.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

snowball said:
I am trying to get an efficiency figure calculation from a start time less
a
finish time less the sum of personal breaks and m/c breaks.

Start time = Tin
Finish Time = TOut
start -less finish Time = workedT
personal breaks = Pbreak
Machine downtime = M/C break

I have managed to calculate the WorkedT by using the datediff function,
DateDiff("n",[TIn],[TOut])\60 & Format(DateDiff("n",[TIn],[TOut]) Mod
60,"\:00") this is now my workedT,

However i now need to subtract the sum of [Pbreak]+[M/C Break] from my
[worked time] and my answer needs to be in Minutes.

Can anyone help.
 

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