Generate date dimension that support working days calculation
SQL Server code to generate date dimension table that supports working days calculation.
I just wrote a T-SQL query based on CTE that generates support information to calculate working days in a period. Simply look at the WorkingDaySequential measure, which difference between two dates is the number of elapsed working days.
In the real world:
- The Holidays CTE could be replaced by a real table with user-inserted data.
- The temporary [#Calendar] could be a real table, providing necessary data access from DM
and probably much else.
The following code is provided "as is", without any warranty about its behavior.
Tags: time dimension