Why postgres show two different format for same interval value?

前端 未结 2 1159

I was helping with this question trying to change the format for the interval.

from \'01 day 22:10:37\'  to  \'46:10:37\'

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-19 02:55

    From https://www.postgresql.org/docs/9.5/static/functions-formatting.html

    to_char(interval) formats HH and HH12 as shown on a 12-hour clock, i.e. zero hours and 36 hours output as 12, while HH24 outputs the full hour value, which can exceed 23 for intervals.

    From https://www.postgresql.org/docs/8.2/static/functions-formatting.html

    to_char(interval) formats HH and HH12 as hours in a single day, while HH24 can output hours exceeding a single day, e.g. >24.

    I'd guess that the first one use implicit format based on the result of the subtraction, and the second use an explicit format based on the input.

提交回复
热议问题