Date conversion problem in sqlserver [Resolved]

Posted by Klbaiju under Sql Server on 6/27/2014 | Points: 10 | Views : 558 | Status : [Member] | Replies : 1
Hi I want to display a date in a particular format

select CONVERT(VARCHAR(20), cdate,106 )as tourdate from Baiju.dbo.tyredetails

this returns as

tourdate
6/25/2014
I want to display this as Jun-25-2014

how it is possible

Regards

Baiju




Responses

Posted by: Kirthiga on: 6/27/2014 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi Baiju

Sql server having various default datetime formats.

To display MMM DD YYYY format [0,9,100,109] are available.

select CONVERT(VARCHAR(11), cdate,0)as tourdate from Baiju.dbo.tyredetails


To display MMM-DD-YYYY format no default formats available. You can try like this.

select convert(varchar(3),datename(month,cdate)) +'-'+ 

convert(varchar,day(cdate)) +'-'+ convert(varchar,year(cdate)) as tourdate
from Baiju.dbo.tyredetails


Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response