时区感知date_trunc函数 [英] timezone aware date_trunc function
本文介绍了时区感知date_trunc函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下查询
SELECT the_date FROM date_trunc('day', timestamp with time zone
'2001-01-1 00:00:00+0100') as the_date
结果为
the_date
2000-12-31 00:00
是否有一种方法可以告诉date_trunc根据其所供给的时区进行日/月/年转换?
Is there a way to tell date_trunc to do day/month/year conversions based on the timezone it is feeded with?
预期的输出将是: 2001-01-1 00:00 + 0100
推荐答案
您需要指定要在哪个时区显示
You need to specify at which time zone you want it to show
select
date_trunc(
'day',
timestamp with time zone '2001-01-1 00:00:00+0100' at time zone '-02'
) as the_date;
the_date
---------------------
2001-01-01 00:00:00
这篇关于时区感知date_trunc函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文