I have a query that generates a report for records found between start and stop dates for workdays only (4 day week). I would like to add holidays to the query. As I work in an industrial manufacturing setting our holidays (at least not all of them) cannot be calculated via code as we are shutdown for 2 weeks in the summer and several non-holidays during Christmas. I thought that I would build a table with holidays to reference to.
Here is the query in SQL that I am using to calculate weekdays including holidays. (I apologize in advance for my poor naming conventions as this was one of my first databases.) If anyone can suggest a good method to remove the holidays I would be grateful.
Autoeng
SELECT ECNBCNVIPtbl.[ECNBCNVIP ID], ECNBCNVIPtbl.[Release Date], ECNDetailtbl.[Actual Implementation Date], DateDiff("d",[ECNBCNVIPtbl].[Release Date],[ECNDetailtbl].[Actual Implementation Date],2) AS DaysDiff, Int([daysdiff]/7) AS Weeks, [daysdiff]-[weeks]*3+IIf(Weekday([ECNDetailtbl].[Actual Implementation Date],2)>5,5-Weekday([ECNDetailtbl].[Actual Implementation Date],2),0)+IIf(Weekday([ECNBCNVIPtbl].[Release Date],2)=6,1,0)+1 AS weekdays
FROM ECNBCNVIPtbl INNER JOIN ECNDetailtbl ON ECNBCNVIPtbl.[ECNBCNVIP ID] = ECNDetailtbl.[ECNBCNVIP ID]
WHERE (((ECNDetailtbl.[Actual Implementation Date]) Between [Forms]![frmDates]![Start Date] And [Forms]![frmDates]![Stop Date]) AND ((ECNBCNVIPtbl.[Do Not Process])<>"Do Not Process");
Here is the query in SQL that I am using to calculate weekdays including holidays. (I apologize in advance for my poor naming conventions as this was one of my first databases.) If anyone can suggest a good method to remove the holidays I would be grateful.
Autoeng
SELECT ECNBCNVIPtbl.[ECNBCNVIP ID], ECNBCNVIPtbl.[Release Date], ECNDetailtbl.[Actual Implementation Date], DateDiff("d",[ECNBCNVIPtbl].[Release Date],[ECNDetailtbl].[Actual Implementation Date],2) AS DaysDiff, Int([daysdiff]/7) AS Weeks, [daysdiff]-[weeks]*3+IIf(Weekday([ECNDetailtbl].[Actual Implementation Date],2)>5,5-Weekday([ECNDetailtbl].[Actual Implementation Date],2),0)+IIf(Weekday([ECNBCNVIPtbl].[Release Date],2)=6,1,0)+1 AS weekdays
FROM ECNBCNVIPtbl INNER JOIN ECNDetailtbl ON ECNBCNVIPtbl.[ECNBCNVIP ID] = ECNDetailtbl.[ECNBCNVIP ID]
WHERE (((ECNDetailtbl.[Actual Implementation Date]) Between [Forms]![frmDates]![Start Date] And [Forms]![frmDates]![Stop Date]) AND ((ECNBCNVIPtbl.[Do Not Process])<>"Do Not Process");