I'm trying to convert a date format to a string, so I can strip off the characters I want. I'm having problems. I have these three statements:
with these results:
effdate is varchar(50). Why doesn't the cast (I've tried using convert as well with the same result) cast the result of the inner convert to text? Also, what's the right way to do this? I want the result 19910101 as text, and was planning to cast the second format as text and use substring and replace to get it.
Code:
select top 1 effdate from temp0
select top 1 convert(datetime, effdate, 112) from temp0
select top 1 cast(convert(datetime, effdate, 112) as varchar(50)) from temp0
Code:
Jan 1 1991 12:00AM
1991-01-01 00:00:00.000
Jan 1 1991 12:00AM