在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

此处的详细信息:提取