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 |
dusturner
Starting Member
2 Posts |
Posted - 2008-11-05 : 09:12:49
|
I have a column (Statusdate) in a table that has a varchar (8) with dates of 080508, 970317 (YYMMD) that I need to convert to Datetime (YYYYMMDD). I have mild SQL knowledge and need help with the Convert TSQL command. |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-05 : 09:26:42
|
DECLARE @Sample VARCHAR(8)SET @Sample = '080508'select cast(case when @sample like '0%' then '20' else '19' end+@Sample as datetime)MadhivananFailing to plan is Planning to fail |
|
|
dusturner
Starting Member
2 Posts |
Posted - 2008-11-05 : 09:53:55
|
Yes, this does work. But as I've said before, I need to change the whole column in a table. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-06 : 01:34:20
|
select cast(case when date_column like '0%' then '20' else '19' end+date_column as datetime)from your_TableMadhivananFailing to plan is Planning to fail |
|
|
|
|
|