Need to convert smalldatetime to: eg; Jan'06

Posted on 2006-11-10
Last Modified: 2008-02-01
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!!!
Question by:fjkilken
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
LVL 33

Expert Comment

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

Expert Comment

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

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

Accepted Solution

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)
LVL 75

Expert Comment

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

Expert Comment

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

Featured Post

Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

695 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