Hi
Don't really know where this fits in cause I don't know where the error is occurring.
First off Access 2010
I have a database which uses a module to calculate workdays excluding holidays. The Holidays are listed in a reference table which is checked by the module. this is output by a make table (select) Query.
Problem is it doesn't recognise the dates from 1/1/2014 - 10/1/2014.
It will recognise any dates either side eg 23/12/2013 - 31/12-2013 and 13/1/2014 and on, so I don't believe it is a date format problem.
This is the module I have borrowed to do this if any help and I have used it extensively in the past with no problems
===================================================
Public Function calcWorkDays(dteStart As Date, dteEnd As Date) As Long
Dim i As Long 'day counter
Dim dteCurDay As Date
'set i = 1 if you want the first date to count as a full day
'or i = 0 if you do not want the first day to count as a full day
i = 0
dteCurDay = dteStart
Do Until dteCurDay >= dteEnd
'check date against holiday table
If 0 = DCount("[HolidayDate]", "tblHolidays", "[HolidayDate] = #" & dteCurDay & "#") Then
'continue checking for weekdays i.e. i increases only if week day value is not 1(Sunday) and not 7(Saturday)
If Weekday(dteCurDay) <> 1 And _
Weekday(dteCurDay) <> 7 Then
i = i + 1
End If
End If
dteCurDay = DateAdd("d", 1, dteCurDay)
Loop
calcWorkDays = i
'based on Calculating Networkdays
End Function
---------------------------------------------------------
Any Ideas
Thanks
Leroy
Don't really know where this fits in cause I don't know where the error is occurring.
First off Access 2010
I have a database which uses a module to calculate workdays excluding holidays. The Holidays are listed in a reference table which is checked by the module. this is output by a make table (select) Query.
Problem is it doesn't recognise the dates from 1/1/2014 - 10/1/2014.
It will recognise any dates either side eg 23/12/2013 - 31/12-2013 and 13/1/2014 and on, so I don't believe it is a date format problem.
This is the module I have borrowed to do this if any help and I have used it extensively in the past with no problems
===================================================
Public Function calcWorkDays(dteStart As Date, dteEnd As Date) As Long
Dim i As Long 'day counter
Dim dteCurDay As Date
'set i = 1 if you want the first date to count as a full day
'or i = 0 if you do not want the first day to count as a full day
i = 0
dteCurDay = dteStart
Do Until dteCurDay >= dteEnd
'check date against holiday table
If 0 = DCount("[HolidayDate]", "tblHolidays", "[HolidayDate] = #" & dteCurDay & "#") Then
'continue checking for weekdays i.e. i increases only if week day value is not 1(Sunday) and not 7(Saturday)
If Weekday(dteCurDay) <> 1 And _
Weekday(dteCurDay) <> 7 Then
i = i + 1
End If
End If
dteCurDay = DateAdd("d", 1, dteCurDay)
Loop
calcWorkDays = i
'based on Calculating Networkdays
End Function
---------------------------------------------------------
Any Ideas
Thanks
Leroy