参考
两个日期字段start_date和end_date
-- 计算相差的天数
SELECT EXTRACT(DAY FROM (end_date - start_date)) AS days_difference
FROM your_table;
-- 计算相差的小时数
SELECT EXTRACT(DAY FROM (end_date - start_date)) * 24 +
EXTRACT(HOUR FROM (end_date - start_date)) AS hours_difference
FROM your_table;
-- 计算相差的分钟数
SELECT EXTRACT(DAY FROM (end_date - start_date)) * 24 * 60 +
EXTRACT(HOUR FROM (end_date - start_date)) * 60 +
EXTRACT(MINUTE FROM (end_date - start_date)) AS minutes_difference
FROM your_table;