Skip to content

Instantly share code, notes, and snippets.

@shamlance
shamlance / Calendar.sql
Created January 21, 2023 09:42 — forked from jbnv/Calendar.sql
SQL Server [Calendar] view.
/*
A view that creates a view of date information, in a range from 2000 to 2179.
Use this view to perform date amd time operations would otherwise be difficult with standard T-SQL methods.
*/
CREATE VIEW [dbo].[Calendar]
AS
SELECT [Date]
,DATEPART(year,[Date]) AS [Year]
,DATEPART(month,[Date]) AS [Month]
,DATEPART(day,[Date]) AS [Day]