Try out a calendar table
Calendar tables are also known in the warehousing world as date dimensions. A calendar table is a helpful utility table which you can use to perform date range calculations quickly and efficiently. This is especially true when dealing with fiscal years, which do not always align to a calendar year, or holidays which may not be on the same date every year.
In our example company, the fiscal year starts on July 1 of the current calendar year, so Fiscal Year 2019 started on July 1, 2019 and goes through June 30, 2020. All of this information is in a table called dbo.Calendar
.
This exercise is part of the course
Time Series Analysis in SQL Server
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Find Tuesdays in December for calendar years 2008-2010
SELECT
c.Date
FROM dbo.___ c
WHERE
c.___ = 'December'
AND c.___ = 'Tuesday'
AND c.___ BETWEEN 2008 AND 2010
ORDER BY
c.Date;