Postgresql时间戳和NULL区别

标签 postgresql datetime null timestamp

我是 PostgreSQL 的新手。我有一个名为 FailureTime 的不带时区的时间戳列。一开始它有 NULL 值。

SELECT 时,我需要获取所有具有 current_timestamp - FailureTime > interval '7' 的条目。

但是当FailureTime 为NULL 时,操作的结果为NULL。 我能否将 NULL 转换为 ZERO 值或以某种方式仅获得 current_timestamp 作为操作结果?

最佳答案

current_timestamp - coalesce(FailureTime, current_timestamp) > interval '7'

关于Postgresql时间戳和NULL区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16720390/

相关文章:

Python psycopg2 语法错误

r - as.Date 如果申请或不申请则返回不同的格式

mysql - 在 MySQL 中选择 NULL 和 NOT NULL 值

c# - 我是否应该测试 Main 的 args 数组中值的无效性

postgresql - 如何在 Postgres 中为 UUID 主键列设置默认值?

sql - NOW() 不能用于查询(它不存在)

php - 如何去掉日期时间末尾多余的零?

sql - 考虑重叠事件计算用户的 "busy duration"

java - 通过套接字发送字符串在 catch 语句中出现 null 错误

postgresql - 在 postgresql where 子句中使用驼峰式列