[英]Convert a given datetime to UTC time based on time zone description in SQL
I have data like the following. 我有如下数据。 The first column is of the type
datetime
, and the second column is the corresponding time zone info, and is of the type nvarchar
. 第一
datetime
类型,第二列为相应的时区信息,类型为nvarchar
。
07/04/2012 14:20:45 EASTERN STANDARD TIME 07/04/2012 13:55:10 INDIAN STANDARD TIME 07/04/2012 10:55:00 CENTRAL STANDARD TIME
How can I convert the datetime column value of all the rows to UTC time? 如何将所有行的datetime列值转换为UTC时间?
Try this 尝试这个
UPDATE dbo.YourTable
SET DateTimeColumn=CASE TimeShift
WHEN N'EASTERN STANDARD TIME'
THEN DATEADD(hour,EasternTimeShift,DateTimeColumn)
WHEN N'INDIAN STANDARD TIME'
THEN DATEADD(hour,IndianTimeShift,DateTimeColumn)
...
ELSE DateTimeColumn
END
This is how I could solve: CLR SQL 这是我可以解决的方法:CLR SQL
http://weblogs.asp.net/farhank/archive/2008/07/04/creating-clr-sql-user-defined-function-to-validate-values-using-regular-expression.aspx http://weblogs.asp.net/farhank/archive/2008/07/04/creating-clr-sql-user-defined-function-to-validate-values-using-regular-expression.aspx
(configuring the db) http://exacthelp.blogspot.in/2012/02/create-assembly-for-assembly-failed.html (配置数据库) http://exacthelp.blogspot.in/2012/02/create-assembly-for-assembly-failed.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.