How do I convert an interval into a number of hours with postgres?

前端 未结 6 865
心在旅途
心在旅途 2020-11-28 22:31

Say I have an interval like

4 days 10:00:00

in postgres. How do I convert that to a number of hours (106 in this case?) Is there a function

6条回答
  •  我在风中等你
    2020-11-28 22:55

    If you want integer i.e. number of days:

    SELECT (EXTRACT(epoch FROM (SELECT (NOW() - '2014-08-02 08:10:56')))/86400)::int
    

提交回复
热议问题