0

我有以下查询:

SELECT 
extract(DOW FROM created_at) as DOW, --Sunday is 0, Saturday is 6--
count(*)
FROM 
zendesk_tickets z
WHERE 
city = 'Los Angeles'
AND 
created_at > '2013-07-08 07:00:00'
AND 
created_at < '2013-07-15 07:00:00'
AND tags NOT LIKE '%m_no_description%'
AND issue_type NOT IN ('Driver Account::Spam', 'Driver Trip Feedback::Wrong address    shown')
AND z.group like '%Driver Support'
AND z.group <> 'Driver Support'
GROUP BY DOW
ORDER BY DOW ASC

哪个输出:

DOW       COUNT
0          52
1          251
2          163
3          117
4          155
5          156
6          79

但是,在我的数据库中,所有时间都以 UTC 为时间戳。无论如何要更改此设置以使时间戳数据出现在晚 7 小时的 PST(太平洋标准时间)中?

4

1 回答 1

3
select created_at at time zone 'PST'
from zendesk_tickets;

如果您还想使用该时区比较where 子句中的值,则需要at time zone 'PST'在每个表达式中使用

于 2013-07-17T07:01:16.700 回答