S
Sue Compelling
Hi (Access2007)
I'm trying to get Klaatu's CalcWorkDays function to work though something's
not quite right in the results. Would appreciate any help that you can
provide. The first row's results are right though the following don't seem
to calculate.
My query results look like this:
In Out DateDiffDays
KlaatuDays
(excl Sat/Sun and last day)
(also excl Pub Hols)
1/02/2010 20/02/2010 14 11
9/02/2010 25/02/2010 12 12
10/02/2010 15/04/2010 46 46
My Query expressions look like this:
KlaatuDays: calcworkdays([in],[out])
DateDiffDays:
DateDiff("d",[In],[out]-(DateDiff("ww",[In],[out],7)+DateDiff("ww",[in],[out],1)))
My "HolDate" (in my Table "Holidays") are this:
HolDate
6/02/2010 (which is a Sat - I was trying to test results though will
take this out)
18/02/2010
19/02/2010
My function looks like this:
Function CalcWorkDays(dtmStart As Date, dtmEnd As Date) As Integer
On Error GoTo CalcWorkDays_Error
'Calculates the number of days between the dates
'Have not added one as I wantto exclude the last date
CalcWorkDays = DateDiff("d", dtmStart, dtmEnd) - _
(DateDiff("ww", dtmStart, dtmEnd, 7) + _
DateDiff("ww", dtmStart, dtmEnd, 1))
'Subtract the Holidays
CalcWorkDays = CalcWorkDays - DCount("*", "holidays", "[holdate] between
#" & dtmStart & "# And #" & dtmEnd & "#")
CalcWorkDays_Exit:
On Error Resume Next
Exit Function
CalcWorkDays_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure CalcWorkDays of Module modDateFunctions"
GoTo CalcWorkDays_Exit
End Function
I'm trying to get Klaatu's CalcWorkDays function to work though something's
not quite right in the results. Would appreciate any help that you can
provide. The first row's results are right though the following don't seem
to calculate.
My query results look like this:
In Out DateDiffDays
KlaatuDays
(excl Sat/Sun and last day)
(also excl Pub Hols)
1/02/2010 20/02/2010 14 11
9/02/2010 25/02/2010 12 12
10/02/2010 15/04/2010 46 46
My Query expressions look like this:
KlaatuDays: calcworkdays([in],[out])
DateDiffDays:
DateDiff("d",[In],[out]-(DateDiff("ww",[In],[out],7)+DateDiff("ww",[in],[out],1)))
My "HolDate" (in my Table "Holidays") are this:
HolDate
6/02/2010 (which is a Sat - I was trying to test results though will
take this out)
18/02/2010
19/02/2010
My function looks like this:
Function CalcWorkDays(dtmStart As Date, dtmEnd As Date) As Integer
On Error GoTo CalcWorkDays_Error
'Calculates the number of days between the dates
'Have not added one as I wantto exclude the last date
CalcWorkDays = DateDiff("d", dtmStart, dtmEnd) - _
(DateDiff("ww", dtmStart, dtmEnd, 7) + _
DateDiff("ww", dtmStart, dtmEnd, 1))
'Subtract the Holidays
CalcWorkDays = CalcWorkDays - DCount("*", "holidays", "[holdate] between
#" & dtmStart & "# And #" & dtmEnd & "#")
CalcWorkDays_Exit:
On Error Resume Next
Exit Function
CalcWorkDays_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure CalcWorkDays of Module modDateFunctions"
GoTo CalcWorkDays_Exit
End Function