我有一个包含用户文化的用户表。我需要从时间文化中获得时间。如需参考,请参阅下表。
UserCulture
------------------------------------------
(UTC-12:00) International Date Line West
(UTC-08:00) Baja California
(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi
(UTC+08:00) Kuala Lumpur, Singapore
(UTC+08:00) Kuala Lumpur, Singapore
(UTC+08:00) Kuala Lumpur, Singapore
(UTC+08:00) Kuala Lumpur, Singapore
(UTC+08:00) Kuala Lumpur, Singapore
(UTC+08:00) Kuala Lumpur, Singapore
(UTC+08:00) Kuala Lumpur, Singapore
(UTC+08:00) Kuala Lumpur, Singapore
我想放弃" +8:00"如果是吉隆坡,新加坡
答案 0 :(得分:1)
如果这只是varchar
列,那么这可以有效:
DECLARE @t TABLE(TimeZone NVARCHAR(max))
INSERT INTO @t VALUES
('(UTC-12:00) International Date Line West'),
('(UTC-08:00) Baja California'),
('(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi'),
('(UTC+08:00) Kuala Lumpur, Singapore')
SELECT TimeZone, SUBSTRING(timezone, 5, 6) AS Time FROM @t
输出:
TimeZone Time
(UTC-12:00) International Date Line West -12:00
(UTC-08:00) Baja California -08:00
(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi +05:30
(UTC+08:00) Kuala Lumpur, Singapore +08:00