In this post we will discuss how to get the weekday name in sql server 2008. Also you can check my previous posts on:
By using the DATEPART() function we can get the weekday name. The DATEPART() function is used to return a single part of a date or time, such as year, quarter, month, day, week, weekday, hour, minute, second, millisecond etc.
Here DATEPART() tooks two parameter like below:
DATEPART ( datepart , date )
date: valid date or datetime expression.
Below is the query that will return weekday name, like if today is friday it will return friday.
Declare @week int
Select case @week
When 1 then ‘Sunday’
When 2 then ‘Monday’
When 3 then ‘Tuesday’
When 4 then ‘Wednesday’
When 5 then ‘Thursday’
When 6 then ‘Friday’