May 31, 2011 at 10:34 pm
Hi All,
I need to convert the below format data(data type of ntext) to "mmm-yyyy" ? How to do this ?
input output
January 2010 > Jan-2010
January 2010 > Jan 2010
February 2010 > Feb 2010
February 2010 > Feb-2010
Input column is of ntext data type.Pls help
June 1, 2011 at 4:52 am
This is a presentation layer task, not a SQL task.
That being said, one way to do it in SQL would be: -
--Create test data
DECLARE @testdata AS TABLE (dates NTEXT)
INSERT INTO @testdata
SELECT 'January 2010'
UNION ALL SELECT 'January 2010'
UNION ALL SELECT 'February 2010'
UNION ALL SELECT 'February 2010'
--Get results
SELECT SUBSTRING(CONVERT(VARCHAR,CONVERT(DATETIME,'01 ' + CONVERT(VARCHAR,dates)),113),4,8)
FROM @testdata
June 1, 2011 at 4:55 am
NText for a date? I wasn't aware dates could reach 2 billion unicode characters in length...
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 1, 2011 at 4:56 am
GilaMonster (6/1/2011)
NText for a date? I wasn't aware dates could reach 2 billion unicode characters in length...
I guess that should've been my first comment - before complaining about presentation layer tasks 😛
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply