Pasha
2005-11-22 20:06:03 UTC
Hello All,
I have multiple VIEWS based on a calendar table in my database. All of them
require the weeks to start on Sunday (Default SQL Server). However, one view
(only) that I created requires Mon-Sun week. SET DATEFIRST 1 is not allowed
in Views nor Functions. Is there any workaround?
Here is my view (very simple):
SELECT DISTINCT
[DATE],
[Date] - (DATEPART(DW, [Date]) - 1) as Mon, -- supposed to return Monday
[Date] + (7 - DATEPART(DW, [Date])) as Sun -- supposed to return Sunday
from dbo.CALENDAR
I have multiple VIEWS based on a calendar table in my database. All of them
require the weeks to start on Sunday (Default SQL Server). However, one view
(only) that I created requires Mon-Sun week. SET DATEFIRST 1 is not allowed
in Views nor Functions. Is there any workaround?
Here is my view (very simple):
SELECT DISTINCT
[DATE],
[Date] - (DATEPART(DW, [Date]) - 1) as Mon, -- supposed to return Monday
[Date] + (7 - DATEPART(DW, [Date])) as Sun -- supposed to return Sunday
from dbo.CALENDAR