T
Tom
I'm trying to get the numbers of seconds between a time and either midnight,
whether my time is before or after midnight. (For jobs that run from one day to
the next. (Or beyond.)) Here's what I'm trying to use:
Global StartDate As Date, StopDate As Variant
Global StartTime As Variant, StopTime As Variant
Global ElapsedTime As Variant, ElapsedSeconds As Variant
Global ElapsedSecondsDay1 As Variant, ElapsedSecondsDay2 As Variant
Global ElapsedDays As Variant
' StopDate = Date
' force StopDate to tomorrow for testing
'
StopDate = 7 / 28 / 2005
StopTime = Time
If StopDate = StartDate Then
ElapsedSeconds = DateDiff("s", StartTime, StopTime)
Else
ElapsedSecondsDay1 = DateDiff("s", StartTime, Time(24, 59, 59))
ElapsedSecondsDay2 = DateDiff("s", Time(0, 0, 0), StopTime)
ElapsedSeconds = ElapsedSecondsDay1 + ElapsedSecondsDay2
ElapsedDays = DateDiff("d", StartDate, StopDate)
ElapsedSeconds = (ElapsedSeconds + ((ElapsedDays - 1) * 86400))
End If
ElapsedTime = ElapsedSeconds \ 60 & ":" & Format(ElapsedSeconds Mod 60,
"00")
But Access (2k) gives me a "Type mismatch" error on line:
ElapsedSecondsDay1 = DateDiff("s", StartTime, Time(24, 59, 59))
And I also can't figure out how to correctly enter tomorrow (7/28/05) for the
StopDate, for testing purposes.
Does anyone know what I'm doing wrong? And how to fix it?
Thanks in advance,
Tom
whether my time is before or after midnight. (For jobs that run from one day to
the next. (Or beyond.)) Here's what I'm trying to use:
Global StartDate As Date, StopDate As Variant
Global StartTime As Variant, StopTime As Variant
Global ElapsedTime As Variant, ElapsedSeconds As Variant
Global ElapsedSecondsDay1 As Variant, ElapsedSecondsDay2 As Variant
Global ElapsedDays As Variant
' StopDate = Date
' force StopDate to tomorrow for testing
'
StopDate = 7 / 28 / 2005
StopTime = Time
If StopDate = StartDate Then
ElapsedSeconds = DateDiff("s", StartTime, StopTime)
Else
ElapsedSecondsDay1 = DateDiff("s", StartTime, Time(24, 59, 59))
ElapsedSecondsDay2 = DateDiff("s", Time(0, 0, 0), StopTime)
ElapsedSeconds = ElapsedSecondsDay1 + ElapsedSecondsDay2
ElapsedDays = DateDiff("d", StartDate, StopDate)
ElapsedSeconds = (ElapsedSeconds + ((ElapsedDays - 1) * 86400))
End If
ElapsedTime = ElapsedSeconds \ 60 & ":" & Format(ElapsedSeconds Mod 60,
"00")
But Access (2k) gives me a "Type mismatch" error on line:
ElapsedSecondsDay1 = DateDiff("s", StartTime, Time(24, 59, 59))
And I also can't figure out how to correctly enter tomorrow (7/28/05) for the
StopDate, for testing purposes.
Does anyone know what I'm doing wrong? And how to fix it?
Thanks in advance,
Tom