T
Tony P
Good Morning, Well it is Here anyway.
I am trying to get a counter to work in access which starts at say 09:00 and
stops at 17:00 restarting again the following morning, but not weekends.
The counter I have at the moment you will probably find rather crude but hey
it works. I have used.
Option Explicit
Function ElapsedTimeString(dateTimeStart As Date, dateTimeEnd As Date,
nameofform, nameofsubform) As String
Dim interval As Double, str As String, days As Variant
Dim hours As String, minutes As String, seconds As String
If IsNull(dateTimeStart) = True Or _
IsNull(dateTimeEnd) = True Then Exit Function
interval = dateTimeEnd - dateTimeStart
days = ((DateDiff("d", dateTimeStart, dateTimeEnd)) _
- ((DateDiff("ww", dateTimeStart, dateTimeEnd, (1)) - Int((1) =
Weekday(dateTimeStart))) _
+ ([Forms](nameofform)(nameofsubform)!BOB) + (DateDiff("ww",
dateTimeStart, dateTimeEnd, (7)) - Int((7) = _
Weekday(dateTimeStart)))))
hours = Format(interval, "h")
minutes = Format(interval, "n")
seconds = Format(interval, "s")
' Days part of the string
str = IIf(days = 0, "", _
IIf(days = 1, days & " Day", days & " Days"))
str = str & IIf(days = 0, "", _
IIf(hours & minutes & seconds <> "000", ", ", " "))
' Hours part of the string
str = str & IIf(hours = "0", "", _
IIf(hours = "1", hours & " Hour", hours & " Hours"))
str = str & IIf(hours = "0", "", _
IIf(minutes & seconds <> "00", ", ", " "))
' Minutes part of the string
str = str & IIf(minutes = "0", "", _
IIf(minutes = "1", minutes & " Minute", minutes & " Minutes"))
str = str & IIf(minutes = "0", "", IIf(seconds <> "0", ", ", " "))
' Seconds part of the string
str = str & IIf(seconds = "0", "", _
IIf(seconds = "1", seconds & " s", seconds & " s"))
ElapsedTimeString = IIf(str = "", "0", str)
End Function
Is anyone able to assist. Is it even possible?
Many Thanks
Tony
I am trying to get a counter to work in access which starts at say 09:00 and
stops at 17:00 restarting again the following morning, but not weekends.
The counter I have at the moment you will probably find rather crude but hey
it works. I have used.
Option Explicit
Function ElapsedTimeString(dateTimeStart As Date, dateTimeEnd As Date,
nameofform, nameofsubform) As String
Dim interval As Double, str As String, days As Variant
Dim hours As String, minutes As String, seconds As String
If IsNull(dateTimeStart) = True Or _
IsNull(dateTimeEnd) = True Then Exit Function
interval = dateTimeEnd - dateTimeStart
days = ((DateDiff("d", dateTimeStart, dateTimeEnd)) _
- ((DateDiff("ww", dateTimeStart, dateTimeEnd, (1)) - Int((1) =
Weekday(dateTimeStart))) _
+ ([Forms](nameofform)(nameofsubform)!BOB) + (DateDiff("ww",
dateTimeStart, dateTimeEnd, (7)) - Int((7) = _
Weekday(dateTimeStart)))))
hours = Format(interval, "h")
minutes = Format(interval, "n")
seconds = Format(interval, "s")
' Days part of the string
str = IIf(days = 0, "", _
IIf(days = 1, days & " Day", days & " Days"))
str = str & IIf(days = 0, "", _
IIf(hours & minutes & seconds <> "000", ", ", " "))
' Hours part of the string
str = str & IIf(hours = "0", "", _
IIf(hours = "1", hours & " Hour", hours & " Hours"))
str = str & IIf(hours = "0", "", _
IIf(minutes & seconds <> "00", ", ", " "))
' Minutes part of the string
str = str & IIf(minutes = "0", "", _
IIf(minutes = "1", minutes & " Minute", minutes & " Minutes"))
str = str & IIf(minutes = "0", "", IIf(seconds <> "0", ", ", " "))
' Seconds part of the string
str = str & IIf(seconds = "0", "", _
IIf(seconds = "1", seconds & " s", seconds & " s"))
ElapsedTimeString = IIf(str = "", "0", str)
End Function
Is anyone able to assist. Is it even possible?
Many Thanks
Tony