SQL Server Date Formats -- ddd

13,557

Solution 1

Many ways to do it, here's one way:

SELECT LEFT(DATENAME(dw, GETDATE()), 3)

Solution 2

You could use the DATENAME method to extract the day and then use the SUBSTRING to only take the first 3 chars.

SELECT SUBSTRING(DATENAME(DW, '09/11/2009'), 1, 3)

Solution 3

I would use
SELECT CONVERT(CHAR(3),DATENAME(weekday,GETDATE()))
so as to avoid using another function in the SQL, the conversion to a CHAR(3) implicitly takes the first 3 characters.

Jonathan

Solution 4

try this

SELECT DATEPART(DW, '1/1/2009')

Read up DATEPART here

http://msdn.microsoft.com/en-us/library/ms174420.aspx

Solution 5

You can't ddd out of the box but you can do the full day

e.g.

select datename(weekday,getdate())

returns 'Monday' and you can just take the first 3 letters.

Share:
13,557
Nick
Author by

Nick

Updated on June 09, 2022

Comments

  • Nick
    Nick almost 2 years

    How do I get the day of the week (in ddd format, so Mon, Tue etc.) in SQL ? I don't see anything about it in the CAST and CONVERT documentation..