Click here to Skip to main content
14,934,026 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Dear Experts,

I want to convert this date 'Thu, 31 Oct 2013 10:51:18 +0000' format to sql server datetime format in sql server. Please help on this to achieve the goal. My requirement is to insert this string date data to a sql server datetime field.
Updated 1-Nov-13 1:10am

Please take a look at this...

SQL Date Time[^]

For SQL Server use CONVERT

INSERT INTO Table1 ([date])
SELECT CONVERT(datetime, '05/09/2013', 103)

Hi Sunil,

If the timezone part is important to you, here is one solution :
select convert(datetime, convert(datetimeoffset, stuff(substring('Thu, 31 Oct 2013 10:51:18 +0000',5,27),26,0,':'),1),1);

You can change the timezone part to see different outputs.

If all of the time zones are +0000 so you can ignore it completely:
select cast( substring('Thu, 31 Oct 2013 10:51:18 +0000',5,22) as datetime)

Using the SUBSTRING is to choose the understandable part for the SQL Server.

Good Luck.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900