newbie question: how to figure hours worked each day 
Author Message
 newbie question: how to figure hours worked each day

I want to create a program that figures the hours worked each day if you input
the time in and the time out.  Sometimes the employee will clock in at 8pm one
day and out 8 am the next day.  I appreciate any ideas.


Tue, 16 Jan 2001 03:00:00 GMT  
 newbie question: how to figure hours worked each day
Copy this code to a button's event procedure to execute it...

'*********************************************************
Dim dteTimeIn As Date, dteTimeOut As Date, sngEmployeeHours As Single

' Assign two times for example purposes only. You'll need to substitute
' another way of entering times that makes sense in your app.
dteTimeIn = #7/29/98 8:00:00 PM#
dteTimeOut = #7/30/98 8:16:00 AM#

' Calculates the difference between time in and time out.
' You might want to change output with the Format function
sngEmployeeHours = DateDiff("n", dteTimeIn, dteTimeOut) / 60

' Display result in a message box.
MsgBox (sngEmployeeHours)
'*********************************************************

Best regards,
John Perkins


Quote:
>I want to create a program that figures the hours worked each day if you
input
>the time in and the time out.  Sometimes the employee will clock in at 8pm
one
>day and out 8 am the next day.  I appreciate any ideas.



Tue, 16 Jan 2001 03:00:00 GMT  
 newbie question: how to figure hours worked each day
Here is something i wrote for a similar app.  I used Access to store the
data.  The database was set up to only handle 3 in's and 3 outs for each
day, but that is easly expanded.  Hope this helps.

Nathan Enright

  Dim Db As Database
  Dim Rs1 As Recordset
  Dim Rs2 As Recordset
  Dim totalHours As Long
  Dim totalSec As Long
  Dim totalMin As Long

  Set Db = OpenDatabase(datapath)
  Set Rs1 = Db.OpenRecordset("Select * from [CurrentPeriod]",
dbOpenSnapshot)

  lblPayStart = Rs1!StartingDate
  lblPayEnds = Rs1!EndingDate

  SQLQ = "Select * From [TimeTable] Where [UserName] = '" & Rs1!CurrentUser
_
         & "' And [Date] >= #" & Rs1!StartingDate & "# And [Date] <= #" _
         & Rs1!EndingDate & "#;"

  Set Rs2 = Db.OpenRecordset(SQLQ, dbOpenSnapshot)

  Do While Rs2.EOF = False
    If Not Rs2!In3 Then
     totalSec = totalSec + DateDiff("s", Rs2!In1, Rs2!Out1) + DateDiff("s",
Rs2!In2, Rs2!Out2) + DateDiff("s", Rs2!In3, Rs2!Out3)
    ElseIf Not Rs2!In2 Then
      totalSec = totalSec + DateDiff("s", Rs2!In1, Rs2!Out1) + DateDiff("s",
Rs2!In2, Rs2!Out2)
    ElseIf Not Rs2!In1 Then
       totalSec = totalSec + DateDiff("s", Rs2!In1, Rs2!Out1)
    End If
    Rs2.MoveNext
  Loop

  totalHours = totalSec / 3600
  totalMin = (totalSec Mod 3600) / 60
  totalSec = (totalSec Mod 3600) Mod 60

  lblTotHours = totalHours
  lblTotMin = totalMin
  lblTotSec = totalSec

Quote:

>Copy this code to a button's event procedure to execute it...

>'*********************************************************
>Dim dteTimeIn As Date, dteTimeOut As Date, sngEmployeeHours As Single

>' Assign two times for example purposes only. You'll need to substitute
>' another way of entering times that makes sense in your app.
>dteTimeIn = #7/29/98 8:00:00 PM#
>dteTimeOut = #7/30/98 8:16:00 AM#

>' Calculates the difference between time in and time out.
>' You might want to change output with the Format function
>sngEmployeeHours = DateDiff("n", dteTimeIn, dteTimeOut) / 60

>' Display result in a message box.
>MsgBox (sngEmployeeHours)
>'*********************************************************

>Best regards,
>John Perkins



>>I want to create a program that figures the hours worked each day if you
>input
>>the time in and the time out.  Sometimes the employee will clock in at 8pm
>one
>>day and out 8 am the next day.  I appreciate any ideas.



Tue, 16 Jan 2001 03:00:00 GMT  
 newbie question: how to figure hours worked each day
Maybe the DateDiff function is what your looking for.  
It's in VB help.

Quote:



>> I want to create a program that figures the hours worked each day if you input
>> the time in and the time out.  Sometimes the employee will clock in at 8pm one
>> day and out 8 am the next day.  I appreciate any ideas.

>1. Make a form with the start and end times for each day
>2. Subtract the difference to get time worked each day
>3. Add up the days, to get a total

The PC Guru, Creator of LPARS Loss Prevention Software


Thu, 18 Jan 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Due Date Calculation - Work Days - Business Hours

2. Calculating Due Dates - Work Days - Business Hours - Helpdesk

3. Converting days to (days and hours)

4. How do I calculate Working Hours (Man Hours)

5. CR7 newbie - Work Days

6. Newbie question, can′t figure it out

7. Help needed with duration - work days conversion to calendar days

8. Determining if given day is a non-work day

9. Total estimated project cost, project duration in working days/calendar days

10. summing hours gives result minus any days

11. Expressing multiple days as over 24 hours

12. Insert Assignments: Resources-tasks-hours a day in Project

 

 
Powered by phpBB® Forum Software