user1817367
user1817367

Reputation: 43

How to convert IST time stored as string into Sql Server DateTime Data type

I have a Varchar data type in my Sql Server table. It is used for saving Date and time in IST as string.

For e.g Sat Sep 01 2012 09:00:00 GMT+0530 (India Standard Time)

Can any one please help me in converting this string into Sql Server Datetime Type, using sql query.

Upvotes: 0

Views: 835

Answers (1)

Joe G Joseph
Joe G Joseph

Reputation: 24046

try this:

declare @dt varchar(50)='Sat Sep 01 2012 09:00:00 GMT+0530'
select CONVERT(datetime,substring(@dt,5,20))


SQL fiddle demo

Upvotes: 1

Related Questions