Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need to convert smalldatetime to: eg; Jan'06

Posted on 2006-11-10
5
Medium Priority
?
204 Views
Last Modified: 2008-02-01
Howdy
I need a quick SELECT statement to convert a smalldatetime field to this format: Jan'06
Eg; 01-23-2006 00:00:00 to Jan'06

thanks a lot!!!
Fergal
0
Comment
Question by:fjkilken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 17914860
select convert(varchar(3),yourDateCol,107) + '''' + substring(convert(varchar(4),yourDateCol,121),2,2)
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 17914866
for example, using the getDate() function:

select convert(varchar(3),getdate(),107) + '''' + substring(convert(varchar(4),getdate(),121),2,2)
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 500 total points
ID: 17914885
OOPS!  but change the last parameter from   2,2  to  3,2

select convert(varchar(3),yourDateCol,107) + '''' + substring(convert(varchar(4),yourDateCol,121),3,2)
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17914910
SELECT CONVERT(varchar(3),getdate())+''''+RIGHT(YEAR(getDate()),2)
0
 
LVL 29

Expert Comment

by:Nightman
ID: 17914912
I was just about to correct you ;)
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question