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 |
afifimk
Starting Member
22 Posts |
Posted - 2008-10-20 : 15:58:16
|
I am not sure where to post this question, but here goes. I have NVARCHAR field where date/time is entered as '200810201045'. I need to convert that to a SQL small date time. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-21 : 00:08:41
|
select CAST(SUBSTRING('200810201045',1,8) + ' ' + SUBSTRING('200810201045',9,2) + ':'+RIGHT('200810201045',2) AS datetime) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-21 : 04:28:38
|
Always use proper DATETIME datatype to store datesMadhivananFailing to plan is Planning to fail |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-21 : 05:07:13
|
quote: Originally posted by visakh16 select CAST(SUBSTRING('200810201045',1,8) + ' ' + SUBSTRING('200810201045',9,2) + ':'+RIGHT('200810201045',2) AS datetime)
orselect cast(stuff(stuff('200810201045',11,0,':'),9,0,' ') as datetime)MadhivananFailing to plan is Planning to fail |
|
|
ssyssy
Starting Member
2 Posts |
Posted - 2008-11-05 : 04:02:29
|
thank you |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-05 : 04:08:42
|
quote: Originally posted by ssyssy thank you
Are you the one who asked the question? MadhivananFailing to plan is Planning to fail |
|
|
|
|
|
|
|