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
Solved

Need to convert smalldatetime to: eg; Jan'06

Posted on 2006-11-10
5
199 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
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.

839 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