Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

convert the string value into varchar Expand / Collapse
Author
Message
Posted Wednesday, December 9, 2009 2:27 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, December 8, 2010 7:22 AM
Points: 46, Visits: 107
I need a help to convert string value into dateformat. like i have a string like '2009-NOV' i want to retrive month after converting dateformat...
Post #831220
Posted Wednesday, December 9, 2009 2:51 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Today @ 8:46 AM
Points: 357, Visits: 1,702


declare @i varchar(25)
set @i='2009-NOV'
select datename(month,cast(@i as datetime))




blog: http://sarveshsingh.com

Twitter: @sarveshsing
Post #831234
Posted Wednesday, December 9, 2009 2:53 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, July 28, 2014 1:07 PM
Points: 579, Visits: 1,807
or this?
Declare @string varchar(20)
SET @string = '2009-Nov-11'

SELECT datepart(m,CONVERT(datetime, @string))



---------------------------------------------------------------------------------
Post #831236
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse