Convert string into date in SQL Server -


conversion failed when converting date and/or time character string.

i'm getting above error when running statement in sql server:

select convert(datetime, 'fri, 15 jan 2016 17:30:05 gmt') 

actually want insert same string format in datetime column

as suggested tim biegeleisen, string needs processed converted. in order convert need strip of day (fri,) , gmt timezone @ end, example:

declare @date varchar(50) = 'fri, 15 jan 2016 17:30:05 gmt' select  convert(datetime, substring(@date, 5, len(@date) - 8), 113) 

this solution strip timezone information, have @ post if want convert utc.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -