Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2011-05-31 : 03:11:35
|
Hi All,I need to convert the below format data to "mmm-yyyy" ? How to do this ?input output January 2010 > Jan-2010January 2010 > Jan 2010February 2010 > Feb 2010February 2010 > Feb-2010March 2010 etc March 2010April 2010April 2010May 2010May 2010June 2010June 2010July 2010July 2010August 2010August 2010Thanks,Gangadhara MSSQL Developer and DBA |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-05-31 : 05:06:54
|
[code]SELECT left(datename(month, convert(datetime, '01 ' + col)), 3) + '-' + datename(year, convert(datetime, '01 ' + col))[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-05-31 : 08:55:31
|
1 Always use proper DATETIME datatype to store dates2 Let the front end application do the formationMadhivananFailing to plan is Planning to fail |
 |
|
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2011-05-31 : 23:11:10
|
I am getting this error.The data types varchar and ntext are incompatible in the add operator.The column which i am operating will be ntext (ex:August 2010) and this can't be changed as it has other impact Pls help me .Thanks,Gangadhara MSSQL Developer and DBA |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-06-01 : 11:10:56
|
select left(ast(col as nvarchar(max)),3)+'-'+left(ast(col as nvarchar(max)),4) from tableMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|