counting more than 24hrs

icemonster

Registered User.
Local time
Today, 07:21
Joined
Jan 30, 2010
Messages
502
hey.

i have this code from awhile back:

Code:
Public Function CalcHrsOneWk(DaysSelected As Byte, HrsPerDay As String) As String
    Dim lngHrsOnly As Long
    Dim varWkHrs, varWkMin, varTotHrsWk, varTotMinWk
    varWkHrs = Val(Left(HrsPerDay, 2)) * DaysSelected
    varWkMin = Val(Right(HrsPerDay, 2)) * DaysSelected
    lngHrsOnly = (varWkMin / 60) - 0.5
    varTotHrsWk = varWkHrs + lngHrsOnly
    varTotMinWk = varWkMin - (lngHrsOnly * 60)
    CalcHrsOneWk = varTotHrsWk & ":" & varTotMinWk
End Function

Code:
Public Function CalcHrsOneDay(StartTime As Variant, EndTime As Variant) As String
'strTotalHrsPerDay = Format(Me.txtStartTime - 1 - Me.txtEndTime, "Short Time")
    CalcHrsOneDay = Format(StartTime - 1 - EndTime, "Short Time")
End Function

i want to be able to say count more than 24hrs. meaning, let's say i put in my start time at 7:00 am, and put the end time at 7:00 am it would then create the schedule from the first day to the next day and count it as 24 hrs.

though this doesn't seem to work.

Code:
Function CalcHoursPerDay(StartHour As Byte, EndHour As Byte) As Long
Dim lngHrsPerDay As Long
If StartHour < EndHour Then
    lngHrsPerDay = EndHour - StartHour
Else
    lngHrsPerDay = (24 - StartHour) + EndHour
End If
CalcHoursPerDay = lngHrsPerDay
End Function
 
Ever heard of datediff?

Example: minutes_elapsed = datediff("n",TimestampStart,timestampEnd)
the result is the number of minutes elapsed between the start and the end timestamp.

Enjoy!
 

Users who are viewing this thread

Back
Top Bottom