T
TechTutors
Hey Folks,
I've done my best to research this so that I wouldn't have to repost this
question ((probably the most commonly asked)). So, before I pose it I'd like
to thank you all for taking the time to help me out...
On the file I import is a "TransDate" On the table these records import
to, the "TransDate" field is set to date/time. On the same table, I have
created a "DaysAged" field that I hope will be populated by the result of
this "crude" formula:
"TransDate" - Today's Date - Weekends and Holidays
To elaborate... I need the number of business days that have transpired
between the original "TransDate" Weekends and holidays should be exluded
(obviously).
I have reviewed the code posted by Klatuu, and others... Unfortunately, I am
but a sprinkle-coder ((so to speak)) and the discussions often went over my
head. I'm hoping someone would be kind enough to show me some guidance in
the matter. More importantly, when I used Klatuu's code the following line
was in red and produced an error:
CalcWorkDays = CalcWorkDays - DCount("*", "holidays", "[holdate] between
#" & dtmStart & "# And #" & dtmEnd & "#")
The following is the code I grabbed from Klatuu in a few other posts:
'---------------------------------------------------------------------------------------
' Procedure : CalcWorkDays
' DateTime : 5/8/2006 16:34
' Author : Dave Hargis
' Purpose : Counts the number of days between two dates excluding Saturdays,
' : Sundays, and any days in the Holidays table
'---------------------------------------------------------------------------------------
'
Function CalcWorkDays(dtmStart As Date, dtmEnd As Date) As Integer
On Error GoTo CalcWorkDays_Error
'Calculates the number of days between the dates
'Add one so all days are included
CalcWorkDays = DateDiff("d", dtmStart, dtmEnd) - _
(DateDiff("ww", dtmStart, dtmEnd, 7) + _
DateDiff("ww", dtmStart, dtmEnd, 1)) + 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
Finally... I have already created tbl_Holidays w/ fields called Holdate
(date/time) and Holdate_Description (text)
Again, any and all help would greatly be appreciated.
Many Thanks!
-E
I've done my best to research this so that I wouldn't have to repost this
question ((probably the most commonly asked)). So, before I pose it I'd like
to thank you all for taking the time to help me out...
On the file I import is a "TransDate" On the table these records import
to, the "TransDate" field is set to date/time. On the same table, I have
created a "DaysAged" field that I hope will be populated by the result of
this "crude" formula:
"TransDate" - Today's Date - Weekends and Holidays
To elaborate... I need the number of business days that have transpired
between the original "TransDate" Weekends and holidays should be exluded
(obviously).
I have reviewed the code posted by Klatuu, and others... Unfortunately, I am
but a sprinkle-coder ((so to speak)) and the discussions often went over my
head. I'm hoping someone would be kind enough to show me some guidance in
the matter. More importantly, when I used Klatuu's code the following line
was in red and produced an error:
CalcWorkDays = CalcWorkDays - DCount("*", "holidays", "[holdate] between
#" & dtmStart & "# And #" & dtmEnd & "#")
The following is the code I grabbed from Klatuu in a few other posts:
'---------------------------------------------------------------------------------------
' Procedure : CalcWorkDays
' DateTime : 5/8/2006 16:34
' Author : Dave Hargis
' Purpose : Counts the number of days between two dates excluding Saturdays,
' : Sundays, and any days in the Holidays table
'---------------------------------------------------------------------------------------
'
Function CalcWorkDays(dtmStart As Date, dtmEnd As Date) As Integer
On Error GoTo CalcWorkDays_Error
'Calculates the number of days between the dates
'Add one so all days are included
CalcWorkDays = DateDiff("d", dtmStart, dtmEnd) - _
(DateDiff("ww", dtmStart, dtmEnd, 7) + _
DateDiff("ww", dtmStart, dtmEnd, 1)) + 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
Finally... I have already created tbl_Holidays w/ fields called Holdate
(date/time) and Holdate_Description (text)
Again, any and all help would greatly be appreciated.
Many Thanks!
-E