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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -