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 - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -