Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitae36661

Browse files
committed
doc: show how interval's 3 unit buckets behave using EXTRACT()
This clarifies when justify_days() and justify_hours() are useful.Paragraph moved too.Reported-by: vodevsh@gmail.comDiscussion:https://postgr.es/m/152698651482.26744.15456677499485530703@wrigleys.postgresql.orgBackpatch-through: 9.3
1 parent39686cd commitae36661

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

‎doc/src/sgml/datatype.sgml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,19 +2688,6 @@ P <optional> <replaceable>years</>-<replaceable>months</>-<replaceable>days</> <
26882688
to each field if any field is negative.
26892689
</para>
26902690

2691-
<para>
2692-
Internally <type>interval</> values are stored as months, days,
2693-
and seconds. This is done because the number of days in a month
2694-
varies, and a day can have 23 or 25 hours if a daylight savings
2695-
time adjustment is involved. The months and days fields are integers
2696-
while the seconds field can store fractions. Because intervals are
2697-
usually created from constant strings or <type>timestamp</> subtraction,
2698-
this storage method works well in most cases. Functions
2699-
<function>justify_days</> and <function>justify_hours</> are
2700-
available for adjusting days and hours that overflow their normal
2701-
ranges.
2702-
</para>
2703-
27042691
<para>
27052692
In the verbose input format, and in some fields of the more compact
27062693
input formats, field values can have fractional parts; for example
@@ -2752,6 +2739,33 @@ P <optional> <replaceable>years</>-<replaceable>months</>-<replaceable>days</> <
27522739
</tgroup>
27532740
</table>
27542741

2742+
<para>
2743+
Internally <type>interval</type> values are stored as months, days,
2744+
and seconds. This is done because the number of days in a month
2745+
varies, and a day can have 23 or 25 hours if a daylight savings
2746+
time adjustment is involved. The months and days fields are integers
2747+
while the seconds field can store fractions. Because intervals are
2748+
usually created from constant strings or <type>timestamp</type> subtraction,
2749+
this storage method works well in most cases, but can cause unexpected
2750+
results:
2751+
2752+
<programlisting>
2753+
SELECT EXTRACT(hours from '80 minutes'::interval);
2754+
date_part
2755+
-----------
2756+
1
2757+
2758+
SELECT EXTRACT(days from '80 hours'::interval);
2759+
date_part
2760+
-----------
2761+
0
2762+
</programlisting>
2763+
2764+
Functions <function>justify_days</function> and
2765+
<function>justify_hours</function> are available for adjusting days
2766+
and hours that overflow their normal ranges.
2767+
</para>
2768+
27552769
</sect2>
27562770

27572771
<sect2 id="datatype-interval-output">

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp