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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time

Status
Not open for further replies.

Danielvb

Programmer
Oct 8, 2002
34
US
Hello programmers:

Please I need help, I am writing a program that deals with date and time.

-- A text file contains the following information
1- EmployeeID
2- Date (format month/day/year)
3- Time (The time is formated like this [Format$(Time, "hh:mm:ss AMPM")])

--The record looks like this one:
125200,"01/16/03","03:53:28 PM"

--Sometimes employees enter at 05:00:00 PM on 01/16/03 and finish working at 03:30:00 AM 01/17/03 which is the next day.

Question?
=======

How can I calculate the work-hours per employee if the shift fall between one day and another one?

Thanks in advace to all for your time

Daniel
vbbeginner@aol.com
Hollywood, FL
 


I'd store both the beginning and ending shift times as a date/time (in Access) data type-which would look like '1/16/03 05:00:00 PM" and '1/17/03 03:30:00 AM". Then you could determine the difference between the times using the DateDiff() or Dateserial functions...

Mark
 
try using the datediff function (see MSDN) i think this can cope with this situation

hours=datediff(h,date1,date2)
 
For each additional day after the day the shift started add 24 hours to the time value. Use a 24 hour clock.

05:00:00 PM on 01/16/03 = 1700
03:30:00 AM 01/17/03=330 + 2400

2730-1700=1030 (shift is 10:30 long) Thanks and Good Luck!

zemp
 

Quick thought using time only...
[tt]
Dim I As Integer
I = DateDiff("h", "05:00:00 PM", "03:30:00 AM")
'I = - 14
[/tt]
I = -14 should throw up some flags for you...

You have start date/time and end date/time so if you...
[tt]
Dim I As Integer
I = DateDiff("h", "01/16/03 03:53:28 PM", "01/17/03 03:30:00 AM")
'i=12
[/tt]

should solve some of your problems...

Good Luck

 
Thanks to all for your tips. I will allways appreciate


Daniel

Hoillywood, FL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top