简体   繁体   English

如何将以字符串形式存储的IST时间转换为Sql Server DateTime数据类型

[英]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. 我的Sql Server表中有一个Varchar数据类型。 It is used for saving Date and time in IST as string. 它用于将IST中的日期和时间另存为字符串。

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. 谁能帮助我使用sql查询将此字符串转换为Sql Server Datetime类型。

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 SQL小提琴演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM