I am trying to calculate a time and this does not seem to calculate the hour. The table that I get the information from has an end time (ex. 7:10:31 AM) and a duration (in seconds - ex. 48610).
I am attempting to calculate the start-time by subtracting the duration from the end time. The problem seems to be that the information that the function is getting when I try to pass the end time adds a date as well . (Ex. 12/29/1899 7:10:31 AM)
If I hard code just the time in the function call then the function works great. (Checktime("7:10:31 AM", 48610) = 3:10:21 PM) However when I pass the date information straight from the table, it tacks the 12/29/1899 date at the beginning.
Public Function CheckTime(Begin As Date, Duration As Long) As Date
CheckTime = TimeSerial(Hour(Begin - Int(Duration \ 3600)), Minute(Begin), _
(Second(Begin) - (Duration - (Int(Duration \ 3600) * 3600))))
End Function
Is there anything I can do to remedy this problem?
Thanks
I am attempting to calculate the start-time by subtracting the duration from the end time. The problem seems to be that the information that the function is getting when I try to pass the end time adds a date as well . (Ex. 12/29/1899 7:10:31 AM)
If I hard code just the time in the function call then the function works great. (Checktime("7:10:31 AM", 48610) = 3:10:21 PM) However when I pass the date information straight from the table, it tacks the 12/29/1899 date at the beginning.
Public Function CheckTime(Begin As Date, Duration As Long) As Date
CheckTime = TimeSerial(Hour(Begin - Int(Duration \ 3600)), Minute(Begin), _
(Second(Begin) - (Duration - (Int(Duration \ 3600) * 3600))))
End Function
Is there anything I can do to remedy this problem?
Thanks