Jul 17, 2008 #1 dolodolo Technical User Joined May 27, 2003 Messages 86 Location 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
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
Jul 17, 2008 #2 SQLSister Programmer Joined Jun 18, 2002 Messages 7,292 Location US try Code: select DATENAME(month, dtdate) "NOTHING is more important in a database than integrity." ESquared Upvote 0 Downvote
try Code: select DATENAME(month, dtdate) "NOTHING is more important in a database than integrity." ESquared
Jul 17, 2008 #3 genomon Programmer Joined Aug 20, 2001 Messages 2,449 Location US 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." Upvote 0 Downvote
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."
Jul 17, 2008 #4 genomon Programmer Joined Aug 20, 2001 Messages 2,449 Location US 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." Upvote 0 Downvote
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."
Jul 17, 2008 #5 SQLSister Programmer Joined Jun 18, 2002 Messages 7,292 Location US 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 Upvote 0 Downvote
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
Jul 17, 2008 Thread starter #6 dolodolo Technical User Joined May 27, 2003 Messages 86 Location US Thanks All for a great and speedy response!!!! Upvote 0 Downvote