Solved

Need to convert smalldatetime to: eg; Jan'06

Posted on 2006-11-10
5
197 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
  • 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 125 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

896 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now