SQL Server 2000
Used to know how to do this but am having no luck today. I have data coming in from a .txt file that gives me char strings for dates, e.g. 02242003 for Feb. 2, 2003.
Need to whomp this into small datetime with the whole convert/cast thing but I guess I've previously only gone the other way--smalldatetime to char.
Thanks!!!declare @.dString char(8)
set @.dString = '02242003'
select cast(substring(@.dString, 5, 4) +
substring(@.dString, 1, 4) as smalldatetime)|||Ok, that's a good step in the right direction. Now, how do I get the result to be 02/24/2003?
Tried Convert(smalldatetime, cast(substring(@.dString, 5, 4) +
substring(@.dString, 1, 4) as smalldatetime), 101) and it barked at me.|||declare @.dString char(8)
set @.dString = '02242003'
select CONVERT(varchar,cast(substring(@.dString, 5, 4) +
substring(@.dString, 1, 4) as smalldatetime),101)|||Brett,
Sorry for not getting back to you. Thanks mucho! This was exactly what I needed.
One bright spot in a lot of messy T-SQL writing!
No comments:
Post a Comment