How To Get Day Of Week In SQL Server?

Sometimes we need to get the day of week in name or number. SQL Server has a couple of inbuilt functions to get the day of week from the given date. To get the name of the day of week, you can use DATENAME function and to get the number of the day of week, you can use DATEPART function.

Example

To get the name of the day of week

SELECT DATENAME(WEEKDAY, GETDATE())

/* Result */
Wednesday

To get the number of the day of week

SELECT DATEPART(WEEKDAY, GETDATE())

/* Result */
4

How to get day of week in SQL Server

Reference

  • About DATENAME function at MSDN.

Related Articles & Tools

Leave your thoughts...