Postgresql 具有当前\u日期的postgres查询不起作用

Postgresql 具有当前\u日期的postgres查询不起作用,postgresql,Postgresql,下面是我在postgres中的查询 select dns_time,update_time from dns_lookup where update_time=current_date; 这里更新时间是带有时区的时间戳类型。 我也试过这个 select dns_time,update_time from dns_lookup where update_time like current_date; 然后也没有结果。 我有当前_日期值的记录。但它没有显示任何记录。如何将时区值的时间戳与当前_

下面是我在postgres中的查询

select dns_time,update_time from dns_lookup where update_time=current_date;
这里更新时间是带有时区的时间戳类型。 我也试过这个

select dns_time,update_time from dns_lookup where update_time like current_date; 
然后也没有结果。 我有当前_日期值的记录。但它没有显示任何记录。如何将时区值的时间戳与当前_日期进行比较。请帮助我
谢谢。

首先:
像日期或时间戳列上的
没有任何意义

时间戳
包含时间部分,因此无法与普通的
日期进行比较。您需要通过将时间戳强制转换为日期来删除时间戳中的时间:

where cast(update_time as date) = current_date;

请注意,这将使
update\u time
上的索引无效。如果这是一个问题,您可以基于该表达式创建一个基于函数的索引。

首先:
类似于日期或时间戳列上的
,没有任何意义

时间戳
包含时间部分,因此无法与普通的
日期进行比较。您需要通过将时间戳强制转换为日期来删除时间戳中的时间:

where cast(update_time as date) = current_date;

请注意,这将使
update\u time
上的索引无效。如果这是一个问题,您可以基于该表达式创建一个基于函数的索引。

您可能正在尝试将
时间戳
字段与
日期
字段进行比较

尝试将时间戳转换为日期

select dns_time,update_time from dns_lookup where update_time::Date=current_date;

希望这有帮助

您可能试图将
时间戳
字段与
日期
字段进行比较

尝试将时间戳转换为日期

select dns_time,update_time from dns_lookup where update_time::Date=current_date;
希望这有帮助