How to get Day or Weekday name from date in Sql Server

Many a times we come across a scenario where we may need to get Day/Weekday name from Date in Sql Server. In this article we will see how we can get Day/Weekday name from Date in Sql Server.

Approach 1: Using DATENAME Function

We can use DATENAME() function to get Day/Weekday name from Date in Sql Server, here we need specify datepart parameter of the DATENAME function as weekday or dw both will return the same result.

SELECT GETDATE() 'Today', DATENAME(weekday,GETDATE()) 'Day Name'
SELECT GetDate() 'Today', DATENAME(dw,GETDATE()) 'Day Name'

RESULT:

Day or weekday name from Date Sql Server 1

Approach 2: Using FORMAT Function

We can aswell use FORMAT function which is introduced in Sql Server 2012 to get Day/Weekday name from Date in Sql Server. It is not an Sql Server native function instead it is .NET CLR dependent function. I would prefer the first approach instead of this approach for getting Day/Weekday name from Date in Sql Server. But FORMAT function provides lot of options compared to DATENAME function. To know more about FORMAT function you may like to go through a detailed article on FORMAT STRING FUNCTION IN SQL SERVER 2012 which I have written couple of years back.

SELECT GETDATE() 'Today', FORMAT(GETDATE(),'dddd') 'Day Name'

RESULT:
Day or weekday name from Date Sql Server 2

One thought on “How to get Day or Weekday name from date in Sql Server

Leave a Reply

Your email address will not be published. Required fields are marked *