如何在 SQL 中将时间转换为 IST?
How to get time converted to IST in SQL?
我在一个名为 DPSDateTime
的 SQL 数据表中有数据。下面显示的是具有值的数据列:
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)
在上面的 table crae_date
列中有 DateTime 值和 State 和 TimeZone 列显示 crea_date
列中值的相应 Sate 和 TimeZones。
我想按名称 ISTTime
添加另一列。我想在此列中显示转换为 IST(印度标准时间)的 crea_date
列的值。
我查看了“How to convert between time zones in SQL Server 2008?”中提供的解决方案。这提供了将单个值转换为另一个 TimeZone 的方法。我需要将具有不同时区的整个列转换为 IST。
提前致谢。
尝试此查询以将时间转换为 IST:
SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30')
我在一个名为 DPSDateTime
的 SQL 数据表中有数据。下面显示的是具有值的数据列:
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)
在上面的 table crae_date
列中有 DateTime 值和 State 和 TimeZone 列显示 crea_date
列中值的相应 Sate 和 TimeZones。
我想按名称 ISTTime
添加另一列。我想在此列中显示转换为 IST(印度标准时间)的 crea_date
列的值。
我查看了“How to convert between time zones in SQL Server 2008?”中提供的解决方案。这提供了将单个值转换为另一个 TimeZone 的方法。我需要将具有不同时区的整个列转换为 IST。
提前致谢。
尝试此查询以将时间转换为 IST:
SELECT SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30')