Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert date to month name

Status
Not open for further replies.

dwight1

IS-IT--Management
Aug 22, 2005
176
US
Can any one advise how to convert date to alpha month.

For example.

10/31/2005 as October 2005 or October

Thanks

Dwight
 
SELECT DATENAME(month, '10/31/2005') AS 'Month Name',
DATENAME(month, '10/31/2005') + ' ' + DATENAME(year, '10/31/2005') AS 'MonthYear Name'


“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
 
I've never had the need to do that, so I don't have a script handy. But it has come up several times, so do a search on this forum and you should find a solution.

-SQLBill

Posting advice: FAQ481-4875
 
Hi Dwight,

easy as:

SELECT datename(m,getdate()) + ' ' + cast(year(getdate()) as char(4))

OR

SELECT datename(m,getdate()) + ' ' + datename(yyyy,getdate())

I would guess that the 2nd version might be a bit slower, but not sure what SQL is doing internally to return the year...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top