Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to convert a Date/Time field to numbers...

Status
Not open for further replies.

sedilson

Programmer
May 12, 2003
13
CA
Okay I need some help please.

I have a form where the user enters a signIn time and a SignOut time for a specific project and i want to get the calculated amount of time worked on that project. how do i accomplish this.

example

signIn @ 12:30Pm SignOut @ 5:30 Pm TotalHours = 5 hours

This is what i have so far inside the txtTotalHrs

=txtSignIn - txtSignOut
 
Use the DateDiff function:

Use the help files and search for DateDiff


"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
Hi,

Try this:

Dim x
x = DateDiff("h", Me!txtSignIn, Me!txtSignOut)
MsgBox x

Good Luck

Bill

 
Thanks Guys that works fine, until......

Okay i have 3 shifts where they can work

shift 1 (8AM - 5PM)
shift 2 (5AM - 10PM)
shift 3 (10PM - 6AM)

the DateDiff seems to work for both the shift 1 and 2 but when it's shift 3 and it goes into an new day it calculates the wrong amount.

so using the DateDiff shift 3 will give me a result of -16 hours worked..

Anyway around this..

Thanks in advance!

 
Stealing/modifying previous code...

Code:
x = DateDiff("h", 0, CDate(Me!txtSignOut) - CDate(Me!txtSignIn))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top