PostgreSQL--如何计算2个日期的秒数差值

extract函数格式:
extract (field from source)
extract函数是从日期或者时间数值里面抽取子域,比如年、月、日等。source必须是timestamp、time、interval类型的值表达式。field是一个标识符或字符串,是从源数据中的抽取的域。

测试

发现计算差值大约是192秒
在这里插入图片描述

select extract(epoch from (test.update_at - test.create_at)) from test;

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_46548855/article/details/134309613