Description:
Query:
In this example we explain that how to find given
date is weekend or not or check inputed date is weekend or not in SQLServer.SQL
Query to check given date is weekend or not.
Here we demonstrate to check the date is weekend or not
in SQL Server.some time in our application we must have scenario in which we
have to disable the date or give proper message to user that given date or inputted date is weekend so please enter the another date.
Sometime also we have to find the report or generate
report based on the weekend or any attendance report with weekend calculation
at that time this below SQL query is very useful for us.
DECLARE @TodayDate DATETIME
SET @TodayDate = GETDATE()
SELECT @TodayDate
SELECT DATENAME(DW, @TodayDate) -- Returns Datename as Sunday, Monday, Tuesday ....
SELECT DATEPART(DW, @TodayDate) -- Returns Date in number 1-Sunday, 2-Monday, ...
7-Saturday
0 comments:
Post a Comment