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 |
KlausEngel
Yak Posting Veteran
85 Posts |
Posted - 2010-10-22 : 12:46:31
|
I have column that stores a date as a char value in the following format:20101023How can I change this into 2010-10-23? |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2010-10-22 : 12:48:24
|
SELECT STUFF(STUFF(datecol,7,0,'-'),5,0,'-') FROM myTableI recommend changing the data type of that column to datetime if you can, if it's only supposed to store dates. |
 |
|
KlausEngel
Yak Posting Veteran
85 Posts |
Posted - 2010-10-22 : 17:31:31
|
Thank you - that's perfect. |
 |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2010-10-22 : 18:52:19
|
SELECT CONVERT(DATETIME,'20101023',101)If you don't have the passion to help people, you have no passion |
 |
|
|
|
|