如何将时间戳数据类型与postgres中的字符串进行比较?

How to compare timestamp data type with string in postgres?

我将日期和时间作为时间戳格式存储在 postgres 中,如下所示:

created_time timestamp without time zone DEFAULT now(),

现在我想搜索在 date_beforedate_after 字段之间具有 created_time 的行。这两个字段都是查询字符串。

我如何用它过滤数据?

在 Postgres 中,您可以简单地将时间戳与字符串进行比较:

select *
from your_table
where created_time >= '2020-06-22 19:10:25-07'
and created_time < '2020-06-23 19:10:25-07'

记得not to use between with time stamps