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

Commitb6e94b8

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 parent2d502b8 commitb6e94b8

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
@@ -2670,19 +2670,6 @@ P <optional> <replaceable>years</replaceable>-<replaceable>months</replaceable>-
26702670
to each field if any field is negative.
26712671
</para>
26722672

2673-
<para>
2674-
Internally <type>interval</type> values are stored as months, days,
2675-
and seconds. This is done because the number of days in a month
2676-
varies, and a day can have 23 or 25 hours if a daylight savings
2677-
time adjustment is involved. The months and days fields are integers
2678-
while the seconds field can store fractions. Because intervals are
2679-
usually created from constant strings or <type>timestamp</type> subtraction,
2680-
this storage method works well in most cases. Functions
2681-
<function>justify_days</function> and <function>justify_hours</function> are
2682-
available for adjusting days and hours that overflow their normal
2683-
ranges.
2684-
</para>
2685-
26862673
<para>
26872674
In the verbose input format, and in some fields of the more compact
26882675
input formats, field values can have fractional parts; for example
@@ -2734,6 +2721,33 @@ P <optional> <replaceable>years</replaceable>-<replaceable>months</replaceable>-
27342721
</tgroup>
27352722
</table>
27362723

2724+
<para>
2725+
Internally <type>interval</type> values are stored as months, days,
2726+
and seconds. This is done because the number of days in a month
2727+
varies, and a day can have 23 or 25 hours if a daylight savings
2728+
time adjustment is involved. The months and days fields are integers
2729+
while the seconds field can store fractions. Because intervals are
2730+
usually created from constant strings or <type>timestamp</type> subtraction,
2731+
this storage method works well in most cases, but can cause unexpected
2732+
results:
2733+
2734+
<programlisting>
2735+
SELECT EXTRACT(hours from '80 minutes'::interval);
2736+
date_part
2737+
-----------
2738+
1
2739+
2740+
SELECT EXTRACT(days from '80 hours'::interval);
2741+
date_part
2742+
-----------
2743+
0
2744+
</programlisting>
2745+
2746+
Functions <function>justify_days</function> and
2747+
<function>justify_hours</function> are available for adjusting days
2748+
and hours that overflow their normal ranges.
2749+
</para>
2750+
27372751
</sect2>
27382752

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp