Saturday, February 25, 2012

Better Way to format day?

I'm trying to find a better way to format the day of the week. What I have stored is the numerical day of the week 1=sunday, 2=monday etc. What I want to display is Sunday, Monday etc. Is there a format that I can use that is better than the case statement below?

select Case Datepart(dw,getdate()) when 1 then 'Sunday'
when 2 then 'Monday'
when 3 then 'Tuesday'
when 4 then 'Wednesday'
when 5 then 'Thursday'
when 6 then 'Friday'
when 7 then 'Saturday' end as DOW

Thanks,

BrentTry this

SELECT datename(dw,getdate())

:)

No comments:

Post a Comment