Date
Jan 9, 2011
SELECT 'Date' =
CASE
WHEN (DATEPART(MONTH,GETDATE()) = 1 ) THEN 'Jan'
WHEN (DATEPART(MONTH,GETDATE()) = 2 ) THEN 'Feb'
WHEN (DATEPART(MONTH,GETDATE()) = 3 ) THEN 'Mar'
WHEN (DATEPART(MONTH,GETDATE()) = 4 ) THEN 'Apr'
WHEN (DATEPART(MONTH,GETDATE()) = 5 ) THEN 'May'
WHEN (DATEPART(MONTH,GETDATE()) = 6 ) THEN 'Jun'
WHEN (DATEPART(MONTH,GETDATE()) = 7 ) THEN 'Jul'
WHEN (DATEPART(MONTH,GETDATE()) = 8 ) THEN 'Aug'
WHEN (DATEPART(MONTH,GETDATE()) = 9 ) THEN 'Sep'
WHEN (DATEPART(MONTH,GETDATE()) = 10 ) THEN 'Oct'
WHEN (DATEPART(MONTH,GETDATE()) = 11 ) THEN 'Nov'
WHEN (DATEPART(MONTH,GETDATE()) = 12 ) THEN 'Dec'
END + ' ' + DATENAME(dd,GETDATE()) + ', '+ DATENAME(yyyy,GETDATE())
The same can be done like this:
ReplyDeleteSELECT Date = LEFT(DATENAME( m, GETDATE()),3) + ' ' + DATENAME(dd,GETDATE()) + ', ' + DATENAME(yyyy,GETDATE())
ALSO
ReplyDeleteSELECT FORMAT([Date],'MMM') AS [Short Month Name]