Solution: Calculating Time Elapsed Between Two Dates
you have a problem he
sDays = ((((sTime / 60) / 60) / 24) Mod 60)
Unless you want that to mean the number of days in the remainder after
dividing the number of days by 60; but not sure that is a standard of any
sort.
--
Regards,
Tom Ogilvy
" wrote:
Here are the components needed to calculate the days, hours, minutes,
and seconds between two dates...
Private Sub Difference()
Dim tStart As Date, tEnd As Date
Dim sTime As String, sDays As String
Dim sHours As String, sMin As String, sSec As String
tStart = Now - 0.12
tEnd = Now
sTime = DateDiff("s", tStart, tEnd)
sDays = ((((sTime / 60) / 60) / 24) Mod 60)
sHours = ((sTime / 60) / 60) Mod 24
sMin = (sTime / 60) Mod 60
sSec = sTime Mod 60
End Sub
tStart and tEnd are only in there to provide a couple of date values
to test the sub with. You can easily modify this to pass in a start
and end date like so:
Private Sub Difference(tStart As Date, tEnd As Date)
and then delete the three lines:
Dim tStart As Date, tEnd As Date
........
tStart = Now - 0.12
tEnd = Now
Thanks!
|