Monday, September 1, 2008

Name of the day in TSQL

I've looked for function returning name of the day in TSQL.

I've found DATENAME which works for me:

SELECT DATENAME(weekday, getdate()) AS 'Day Name'

DateNamea accepts also another arguments converting dates to names:


year yy, yyyy
quarter qq, q
month mm, m
dayofyear dy, y
day dd, d
week wk, ww
weekday dw
hour hh
minute mi, n
second ss, s
millisecond ms

(Note you can use "day", as well as abbreviation "d" - all listed above)

Labels: ,