Subtracting time

  • Thread starter Thread starter Katrina
  • Start date Start date
K

Katrina

I have the fields End Time, start time and hours worked.

I would like access to subtract start time from end time
to give me hours worked after inputting the end time.

It is not working out. I want a number field. For
example, if I start @ 1:00 PM and end at 2:15 PM I want
the hours worked to say 1.25.

I plan on using this in the After Update method. ANy
suggestions?
 
I have the fields End Time, start time and hours worked.

I would like access to subtract start time from end time
to give me hours worked after inputting the end time.

It is not working out. I want a number field. For
example, if I start @ 1:00 PM and end at 2:15 PM I want
the hours worked to say 1.25.

I plan on using this in the After Update method. ANy
suggestions?

Use the DateDiff() function. Despite the name, it's functional for
times as well. If you want fractional hours, calculate the difference
in miNutes and divide by sixty:

Round(DateDiff("n", [StartTime], [EndTime]) / 60., 2)
 
FOr some reason, this command is only giving me whole
housrs.... I copied it exactly how you have it...

Any suggestions?
-----Original Message-----
I have the fields End Time, start time and hours worked.

I would like access to subtract start time from end time
to give me hours worked after inputting the end time.

It is not working out. I want a number field. For
example, if I start @ 1:00 PM and end at 2:15 PM I want
the hours worked to say 1.25.

I plan on using this in the After Update method. ANy
suggestions?

Use the DateDiff() function. Despite the name, it's functional for
times as well. If you want fractional hours, calculate the difference
in miNutes and divide by sixty:

Round(DateDiff("n", [StartTime], [EndTime]) / 60., 2)



.
 
FOr some reason, this command is only giving me whole
housrs.... I copied it exactly how you have it...

Any suggestions?

-----Original Message-----
HrsWorked = DateDiff("n", [StartTime], [EndTime]) / 60


--
Ken Snell
<MS ACCESS MVP>

I have the fields End Time, start time and hours worked.

I would like access to subtract start time from end time
to give me hours worked after inputting the end time.

It is not working out. I want a number field. For
example, if I start @ 1:00 PM and end at 2:15 PM I want
the hours worked to say 1.25.

I plan on using this in the After Update method. ANy
suggestions?


.
 
check what DateDiff("n", [StartTime], [EndTime]) returns in your case
should be number of minutes between 2 times

--
Alex Dybenko (MVP)
http://Alex.Dybenko.com


Katrina said:
FOr some reason, this command is only giving me whole
housrs.... I copied it exactly how you have it...

Any suggestions?
-----Original Message-----
I have the fields End Time, start time and hours worked.

I would like access to subtract start time from end time
to give me hours worked after inputting the end time.

It is not working out. I want a number field. For
example, if I start @ 1:00 PM and end at 2:15 PM I want
the hours worked to say 1.25.

I plan on using this in the After Update method. ANy
suggestions?

Use the DateDiff() function. Despite the name, it's functional for
times as well. If you want fractional hours, calculate the difference
in miNutes and divide by sixty:

Round(DateDiff("n", [StartTime], [EndTime]) / 60., 2)



.
 
Ken's formula is spot on.

For further info on how to work with elapsed time, see:
http://allenbrowne.com/casu-13.html

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

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

FOr some reason, this command is only giving me whole
housrs.... I copied it exactly how you have it...

Any suggestions?

-----Original Message-----
HrsWorked = DateDiff("n", [StartTime], [EndTime]) / 60


--
Ken Snell
<MS ACCESS MVP>

I have the fields End Time, start time and hours worked.

I would like access to subtract start time from end time
to give me hours worked after inputting the end time.

It is not working out. I want a number field. For
example, if I start @ 1:00 PM and end at 2:15 PM I want
the hours worked to say 1.25.

I plan on using this in the After Update method. ANy
suggestions?
 
FOr some reason, this command is only giving me whole
housrs.... I copied it exactly how you have it...

What's the context? Where are you using the expression?

If you're setting the value of an Integer or Long Integer field to the
expression, you'll get this effect: Integers, by definition, are whole
numbers.
 
Back
Top