Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql Postgres按日期和时区计数_Postgresql_Timezone - Fatal编程技术网

Postgresql Postgres按日期和时区计数

Postgresql Postgres按日期和时区计数,postgresql,timezone,Postgresql,Timezone,我想查询一个表,找出Postgres中按日期、日期和月份创建的对象的数量 过去30天的提取计数 按天取数 按月提取计数 这对我来说很好。我遇到的问题是,我希望根据不同的时区获取数据。我已将时间存储在UTC中。我可以在不同的时区运行这些查询 最好的方法是什么?勾选此项以获取不同时区的Postgres中的日期时间 过去30天的提取计数 按天取数 按月提取计数 也可以参考这篇博文来了解带有日期时间的时区 SELECT d.date, count(se.id) FROM (SELECT to_char(

我想查询一个表,找出Postgres中按日期、日期和月份创建的对象的数量

过去30天的提取计数

按天取数

按月提取计数

这对我来说很好。我遇到的问题是,我希望根据不同的时区获取数据。我已将时间存储在
UTC
中。我可以在不同的时区运行这些查询

最好的方法是什么?

勾选此项以获取不同时区的Postgres中的日期时间

过去30天的提取计数

按天取数

按月提取计数

也可以参考这篇博文来了解带有日期时间的时区

SELECT d.date, count(se.id)
FROM (SELECT to_char(date_trunc('day', (current_date - offs)), 'YYYY-MM-DD') AS date 
FROM generate_series(0, 30) AS offs) d LEFT OUTER JOIN
     someTable se 
     ON d.date = to_char(date_trunc('day', se.created_at), 'YYYY-MM-DD')  
GROUP BY d.date;
select to_char(created_at,'day') as Day,
       extract(month from created_at) as Date,
       count("id") as "Count"
from someTable
group by 1,2
select to_char(created_at,'Mon') as mon,
       extract(year from created_at) as yyyy,
       count("id") as "Count"
from someTable
group by 1,2
SELECT d.date, count(se.id)
FROM (SELECT to_char(date_trunc('day', (current_date - offs)), 'YYYY-MM-DD') AS date 
FROM generate_series(0, 30) AS offs) d LEFT OUTER JOIN
     someTable se 
     ON d.date = to_char(date_trunc('day', se.created_at::timestamp with time zone at time zone 'EST'), 'YYYY-MM-DD')  
GROUP BY d.date;
select to_char(created_at::timestamp with time zone at time zone 'EST','day') as Day,
       extract(month from created_at) as Date,
       count("id") as "Count"
from someTable
group by 1,2
select to_char(created_at::timestamp with time zone at time zone 'EST','Mon') as mon,
       extract(year from created_at) as yyyy,
       count("id") as "Count"
from someTable
group by 1,2