views:

111

answers:

3

I want to convert date format from 01/09 to January 2009 , 09/03 to September 2003 etc. Is this possible in SQL? Please let me know if there is a API for the same.

+1  A: 

if you have a DateTime column in your table, it's possible

SELECT DATENAME(MM, YOUR_DATE_COLUMN) + ' ' + CAST(YEAR(YOUR_DATE_COLUMN) AS VARCHAR(4)) AS [Month YYYY]

http://www.sql-server-helper.com/tips/date-formats.aspx

roman m
A: 

You should look here.

It's rather simple.

SirDemon
A: 

You should first convert it to a datetime. Then you can easily apply any formating when you read it later.

declare @d varchar(10);
set @d = '01/09'

select 
  --cast(@d as datetime) as d1, --syntax error converting char string
  cast('20' + right(@d, 2) + '-' + left(@d, 2) + '-01' as datetime) as d2

then convert it to mmm yyyy using rm's answer

dotjoe