The below query displays the firstday and Lastday of a Current Week:
DECLARE
DECLARE
SELECT @StartDate DATETIME @ENDDATE DATETIME @STARTDATE = (SELECT min(d) AS WeekBeginFROM (SELECT [DATE] AS D FROMDIMDATE WHERE YEAR([DATE]) = YEAR(GETDATE())
AND Datepart(WEEK, GETDATE()) = DIMDATE.WEEKOFYEAR)t)SELECT @ENDDATE = (SELECT MAX(d) AS WeekBeginFROM (SELECT [DATE] AS D FROMDIMDATE WHERE YEAR([DATE]) = YEAR(GETDATE())
AND Datepart(WEEK, GETDATE()) = DIMDATE.WEEKOFYEAR)t)SELECT @startdate AS FirstDay, @Enddate AS LastDay
No comments:
Post a Comment