如何在SQL中将时间转换为IST?

时间:2015-01-12 10:47:19

标签: sql sql-server timezone

我在一个SQL DataTable中有一个名为DPSDateTime的数据。下面显示的是具有值的数据列:

crea_date                      Disp_Day             Disp_Time      State        TimeZone
11/13/14 5:56 PM    Thursday, December 18, 2014     19:00:09        IL  (GMT-06:00) Central Time (US & Canada)
11/24/14 11:17 AM   Wednesday, December 24, 2014    10:27:44    WA  (GMT-07:00) Mountain Time (US & Canada)
12/12/14 1:19 PM    Wednesday, December 24, 2014    19:24:33    WI  (GMT-06:00) Central Time (US & Canada)
12/13/14 12:05 PM   Thursday, December 25, 2014     12:36:27        CA  (GMT-05:00) Eastern Time (US & Canada)
12/17/14 11:33 AM   Monday, December 29, 2014       08:16:35        OR  (GMT-08:00) Pacific Time (US & Canada); Tijuana
12/17/14 2:03 PM    Thursday, December 25, 2014     13:00:21        CA  (GMT-05:00) Eastern Time (US & Canada)
12/18/14 11:05 AM   Thursday, December 25, 2014     15:06:44        TX  (GMT-06:00) Central Time (US & Canada)
12/18/14 9:16 AM    Thursday, December 25, 2014     07:59:16        WA  (GMT-07:00) Mountain Time (US & Canada)
12/18/14 5:27 PM    Saturday, December 20, 2014     11:23:04        WA  (GMT-07:00) Mountain Time (US & Canada)
12/19/14 10:07 AM   Monday, December 29, 2014       06:55:31        LA  (GMT-06:00) Central Time (US & Canada)
12/22/14 4:44 PM    Monday, December 22, 2014       18:20:27        NJ  (GMT-05:00) Eastern Time (US & Canada)
12/22/14 4:53 PM    Monday, December 22, 2014       17:47:08        OK  (GMT-06:00) Central Time (US & Canada)
12/23/14 1:31 PM    Friday, December 26, 2014       18:37:00        NH  (GMT-05:00) Eastern Time (US & Canada)
12/23/14 3:18 PM    Tuesday, December 23, 2014      21:25:26        MS  (GMT-06:00) Central Time (US & Canada)
12/23/14 4:37 PM    Friday, December 26, 2014       15:28:04        MD  (GMT-05:00) Eastern Time (US & Canada)

在上表crae_date列中有DateTime Value,State和TimeZone Columns显示crea_date列中值的相应Sate和TimeZones。

我想通过名称ISTTime添加另一个列。我想在此列中显示转换为IST(印度标准时间)的crea_date列的值。

我检查了“How to convert between time zones in SQL Server 2008?”中提供的解决方案。这给出了将单个值转换为另一个TimeZone的方法。我需要将具有不同时区的整个列转换为IST。

提前致谢。

1 个答案:

答案 0 :(得分:2)

尝试此查询以将时间转换为IST:

Android 6