select concat(CURRENT_DATE, ' ', '00:00:00+02:00')
返回"2020-07-14 00:00:00+02:00"
我可以将此结果复制粘贴到我的WHERE
子句中:
where (xyz between timestamp with time zone '2020-06-01 00:00:00+02:00'
and timestamp with time ZONE 2020-07-14 00:00:00+02:00
它有效,但是如果我使用更具动态性的结构concat(CURRENT_DATE, ' ', '00:00:00+02:00')
,则:
where (xyz between timestamp with time zone '2020-06-01 00:00:00+02:00'
and timestamp with time ZONE concat(CURRENT_DATE, ' ', '00:00:00+02:00')
我收到语法错误:
错误:“ concat”第57行处或附近的语法错误:... 6-01 00:00:00 + 02:00',时间戳记与时间ZONE concat(CUR ...
为什么第一个WHERE子句起作用,但另一个却不起作用,即使它以相同的格式打印相同的日期呢?
答案 0 :(得分:2)
您可以使用at time zone
:
where xyz between ('2020-06-01'::date at time zone '+02:00') and (current_date at time zone '+02:00')