PostgreSQL:格式间隔以分钟为单位 [英] PostgreSQL: format interval as minutes
本文介绍了PostgreSQL:格式间隔以分钟为单位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我减去时间戳记时,时间间隔的格式为DD:HH:MM:SS。如何将它们全部转换为分钟而又不提取日期和时间以及乘法/加法?我正在寻找一个可以代替此查询中的 date_part
的函数,使其返回65:
When I subtract timestamps, the interval is in form DD:HH:MM:SS. How can I convert it all to minutes without extracting days and hours and multiplication/addition? I'm looking for a single function which I can substitute for date_part
in this query so that it returns 65:
select date_part('minutes', '65 minutes'::interval);
上下文:我需要知道自给定时间戳记以来已经过了多少分钟。
Context: I need to know how many minutes have passed since given timestamp.
推荐答案
SELECT EXTRACT(EPOCH FROM '2 months 3 days 12 hours 65 minutes'::INTERVAL)/60;
似乎可以正常工作。
警告: 似乎是关键词。
WARNING: "seems" is the key word.
这篇关于PostgreSQL:格式间隔以分钟为单位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文