如何检查两个时间戳 postgres 之间是否有时间戳?
How to check if timestamp between two timestamps postgres?
我正在开发一个 spring api,我正在使用 postgres 并保存一个时间戳类型的字段,字段名称为 created_date
。现在我想检查这个字段是否在两个不同的时间戳之间。
现在我正在使用这个:
select *
from your_table
where created_date >= '2020-06-22 19:10:25-07'
and created_date < '2020-06-23 19:10:25-07'
有什么方法可以在这里使用 BETWEEN
来进行这个操作吗?
你可以这样做:
SELECT *
FROM your_table
WHERE created_date BETWEEN '2020-06-22 19:10:25-07'
AND '2020-06-23 19:10:25-07'
如果您想使用 JDBC 执行此操作,请选中 this answer and this answer。
我正在开发一个 spring api,我正在使用 postgres 并保存一个时间戳类型的字段,字段名称为 created_date
。现在我想检查这个字段是否在两个不同的时间戳之间。
现在我正在使用这个:
select *
from your_table
where created_date >= '2020-06-22 19:10:25-07'
and created_date < '2020-06-23 19:10:25-07'
有什么方法可以在这里使用 BETWEEN
来进行这个操作吗?
你可以这样做:
SELECT *
FROM your_table
WHERE created_date BETWEEN '2020-06-22 19:10:25-07'
AND '2020-06-23 19:10:25-07'
如果您想使用 JDBC 执行此操作,请选中 this answer and this answer。