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 |
|
joriveek
Starting Member
33 Posts |
Posted - 2007-04-02 : 06:39:00
|
| Hi I am getting the date in the form of varchar(14) like sayx = '20040102102425'it is like YYYYMMDDHHMMSSNow I want to convert this string as normal datetime and store into SQL table. I think it is DD/MM/YYYY HH:MM:SSIs there any way I can do this SQL Server 2005? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-02 : 06:44:50
|
| [code]DECLARE @x VARCHAR(14)SET @x = '20040102102425'SELECT @x, STUFF(STUFF(STUFF(@x, 9, 0, ' '), 12, 0, ':'), 15, 0, ':'), CAST(STUFF(STUFF(STUFF(@x, 9, 0, ' '), 12, 0, ':'), 15, 0, ':') AS DATETIME)[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|
|