Click here to Skip to main content
16,016,391 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
In Oracle i have below statement:

to_char(im_ason_date,'MON YY')

where im_ason_date is of date type in format 2013-08-20

how can I achieve this format 'MMM YY' for 2013-08-20
 in MS sql serer ? 


I have used beelow query,

SELECT CONVERT(nvarchar(30), CAST('2013-08-20' AS Date), 107) AS Date

output:Aug 20, 2013

how to get rid of year ??
Posted
Updated 28-Jan-14 19:58pm
v2

1 solution

From this
SQL
SELECT	CONVERT(nvarchar(30), CAST('2013-08-20' AS Date), 107) AS Date

you can select it into separate values
SQL
SELECT DATENAME(MONTH, Date) + '.' + DATENAME(DAY,Date) + '.' + DATENAME(YEAR, Date)


Something like this...
SQL
declare @Date as DATE

@Date = CONVERT(nvarchar(30), CAST('2013-08-20' AS Date))

SELECT DATENAME(MONTH, @Date) + SPACE(1) + DATENAME(DAY, @Date)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900