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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert DateTime to 3-char month

Status
Not open for further replies.

dolodolo

Technical User
May 27, 2003
86
US
Hi,

I am looking for the code to convert a date field to a 3-character month - e.g. JUL. Here's what I have but it's just returning the number.

select convert(varchar, (datepart(mm, dtdate))) from cmrevision

Any help is most appreciated.

Thanks
 
try
Code:
select  DATENAME(month,  dtdate)

"NOTHING is more important in a database than integrity." ESquared
 
Instead of DATEPART, try DATENAME and then use LEFT(name,3).

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
I posted the same time as SQL Sis (so didn't see her reply)- as usual, her solution is more elegant in its simplicity, and also the way to go.

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Genomon I think you are right and dolodolo still might need to use the left function.
Code:
select  left(DATENAME(month,  dtdate),3) from cmrevision

"NOTHING is more important in a database than integrity." ESquared
 
Thanks All for a great and speedy response!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top