java - 如何在postgres中比较时间戳数据类型和字符串?
问题描述
我将日期和时间作为时间戳格式存储在 postgres 中,如下所示:
created_time timestamp without time zone DEFAULT now(),
现在我想搜索具有created_time
betweendate_before
和date_after
字段的行。这两个字段都是查询字符串。
我怎样才能用这个过滤数据?
解决方案
在 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'
推荐阅读
- bash - 将文本文件读入bash中的变量
- python - Apache Zeppelin 问题 - Python 错误
- c# - MongoDB 驱动程序不会通过 Nuget 安装
- php - 带反斜杠的 JSON (PHP)
- dataweave - 将字符串转换为布尔型 Mule4 Dataweave
- java - 字节流的内部工作。写(65)和写('A')之间的区别?
- php - NOT instanceof:不属于某个类的对象
- python - 使用 Pandas 和 Python 在 2 个表之间映射数据
- mongodb - 尝试保存到 mongodb 时身份验证失败
- java - Java 只更新 jre 而不是 jdk