SQL Server query (view) Convert String to DateTime -


i'm bit rusty , seem have forgot how this. receiving data , datatime column in string format char(12).

example : 201411061900

how write query (view) convert datetime?

i've used convert (datetime, dbo.kwh.mr_dtm,120), error conversion failed when converting date and/or time character string.

i haven't had luck. thank in advance.

if want suggest -5 time zone also, wouldn't mind. :)

magnus answered question. wanted post here incase helps in future. here link answer.

there no output format identifier (like example 120) lets convert char(12) datetime in sql server. use substring function:

select cast(substring(dbo.kwh.mr_dtm,1,8) + ' ' + substring(dbo.kwh.mr_dtm,9,2)+':'+ substring(dbo.kwh.mr_dtm,11,2) datetime) 

thank everyone! appreciated.
oh, , post me solve timezone setup.

convert datetime column utc local time in select statement

many michael goldshteyn timezone convert.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -