user11934472
user11934472

Reputation:

How to calculate the minute in DTPICKER vb6

I'm creating a payroll system I want to calculate the minute late of Employee using two dtpicker Dtpicker1 is for time in and Dtpicker2 for Timeout

               Private Sub calc_Click()
               oras = DateDiff("n", DTPicker1, DTPicker2)
               Text1.Text = oras
               End sub

Upvotes: 0

Views: 105

Answers (1)

Étienne Laneville
Étienne Laneville

Reputation: 5031

If all employees are working the same amount of hours (8 hours/day for example):

Private Sub calc_Click()
    Dim iWorkdayHours As Integer
    Dim iMinutesWorked As Integer
    Dim iMinutesLate As Integer

    ' Get the amount of minutes between two dates
    iMinutesWorked = DateDiff("n", DTPicker1, DTPicker2)

    ' Get number of hours employee should have worked
    iWorkdayHours = 8

    iMinutesLate = (iWorkdayHours * 60) - iMinutesWorked

    If iMinutesLate > 0 Then
        Text1.Text = iMinutesLate & " minutes late."
    Else
        Text1.Text = "On time."
    End If

End Sub

If employees have different shift lengths, you can update iWorkdayHours.

Upvotes: 2

Related Questions