在PostgreSQL中找到时间戳之间的差异(以秒为单位) [英] Find difference between timestamps in seconds in PostgreSQL

查看:335
本文介绍了在PostgreSQL中找到时间戳之间的差异(以秒为单位)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 PostgreSQL 8.3 中有一个表,带有2个 timestamp 列。我想在几秒钟内获得这些时间戳之间的差异。

I have a table in PostgreSQL 8.3 with 2 timestamp columns. I would like to get the difference between these timestamps in seconds. Could you please help me how to get this done?

TableA
(
  timestamp_A timestamp,
  timestamp_B timestamp
)

我需要得到类似 (timestamo_B-timestamp_A)以秒为单位(不仅仅是秒之间的差,还应该包括小时,分钟等)

I need to get something like (timestamo_B - timestamp_A) in seconds (not just the difference between seconds, it should include hours, minutes etc).

推荐答案

Try: 

Try: 

SELECT EXTRACT(EPOCH FROM (timestamp_B - timestamp_A))
FROM TableA

此处的详细信息:提取

这篇关于在PostgreSQL中找到时间戳之间的差异(以秒为单位)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆