How to get the name of the day of date - SimonS Blog on SQL Server Stuff

How to get the name of the day of date

Do you have a date and you want the day of the week but not the number but the name i.e. Monday, Tuesday etc. Well there are two functions that you can use with dates that can be used to extract a part of the date. One function returns the number and one returns text version. The functions are DATEPART and DATENAME respectively.

Both take a parameter that is the part of the date you want, see BOL for the complete list of options, a couple are

dw = day of week

m = month

so DATENAME(dw,'3 sept 2007') = 'Monday'



-
Published 03 September 2007 22:44 by simonsabin

Comments

04 September 2007 11:42 by Madhivanan

# re: How to get the name of the day of date

Well. That should be DATENAME(dw,'3 sep 2007')

But I prefer using fully qulified names

DATENAME(weekday,'3 sep 2007')

DATEADD(month,3,GETDATE())

etc

for better clarity Smile

# Weekly Link Post 6 « Rhonda Tipton’s WebLog

Pingback from  Weekly Link Post 6 « Rhonda Tipton’s WebLog