var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: cast/convert nvarchar to datetime
How to convert '20100414103010' to datetime? format is yyyymmddhhmmss
The column is nvarchar(14)
I have tried
cast (c1 as datetime)
convert (datetime, c1)
but all i get is 'Conversion failed when converting datetime from character string.'
thx for any help
The first question (of course) is why on earth are you storing dates as a unicode string?
You need to change your string to a format that can be converted.
Have a look at the STUFF() function for T-SQL to get your string in to that format.
SELECT CAST('20100414 10:30:10' AS DATETIME)
thx for fast replay, this works just fine
cast (stuff(stuff(stuff(c1,13,0,':'),11,0,':'),9,0,' ') as datetime)
Last edited by mrpcguy; 04-15-10 at 06:42.