We can use DATENAME
, DATEPART
functions by passing respective parameters to return the day name of the week, day of the week and month names.
SELECT DATENAME(WEEKDAY, GETDATE()) as DayName, DATEPART(WEEKDAY, GETDATE()) as DayOfTheWeek, DATENAME(MONTH, GETDATE()) As MonthName
Following are valid parameters value that can be passed to DATEPART function.
Notice that the same above result can be retrieved by passing abbreviations instead of full datepart parameter value.
SELECT DATENAME(dw, GETDATE()) as DayName, DATEPART(dw, GETDATE()) as DayOfTheWeek, DATENAME(m, GETDATE()) As MonthName
Above query will give the same result as the previous one.
Views: 67851 | Post Order: 74