Need to convert smalldatetime to: eg; Jan'06

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
fjkilkenAsked:
Who is Participating?
 
knightEknightCommented:
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
 
knightEknightCommented:
select convert(varchar(3),yourDateCol,107) + '''' + substring(convert(varchar(4),yourDateCol,121),2,2)
0
 
knightEknightCommented:
for example, using the getDate() function:

select convert(varchar(3),getdate(),107) + '''' + substring(convert(varchar(4),getdate(),121),2,2)
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
SELECT CONVERT(varchar(3),getdate())+''''+RIGHT(YEAR(getDate()),2)
0
 
NightmanCTOCommented:
I was just about to correct you ;)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.