| Author |
Topic  |
|
|
afifimk
Starting Member
USA
19 Posts |
Posted - 10/20/2008 : 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
India
47023 Posts |
Posted - 10/21/2008 : 00:08:41
|
| select CAST(SUBSTRING('200810201045',1,8) + ' ' + SUBSTRING('200810201045',9,2) + ':'+RIGHT('200810201045',2) AS datetime) |
 |
|
|
madhivanan
Premature Yak Congratulator
India
22460 Posts |
Posted - 10/21/2008 : 04:28:38
|
Always use proper DATETIME datatype to store dates
Madhivanan
Failing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
India
22460 Posts |
Posted - 10/21/2008 : 05:07:13
|
quote: Originally posted by visakh16
select CAST(SUBSTRING('200810201045',1,8) + ' ' + SUBSTRING('200810201045',9,2) + ':'+RIGHT('200810201045',2) AS datetime)
or select cast(stuff(stuff('200810201045',11,0,':'),9,0,' ') as datetime)
Madhivanan
Failing to plan is Planning to fail |
 |
|
|
ssyssy
Starting Member
2 Posts |
Posted - 11/05/2008 : 04:02:29
|
| thank you |
 |
|
|
madhivanan
Premature Yak Congratulator
India
22460 Posts |
Posted - 11/05/2008 : 04:08:42
|
quote: Originally posted by ssyssy
thank you
Are you the one who asked the question? 
Madhivanan
Failing to plan is Planning to fail |
 |
|
| |
Topic  |
|