Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dbf57d3

Browse files
committed
Add some documentation about handling of fractions in interval input.
(It's always worked like this, but we never documented it before.)
1 parent df7641e commit dbf57d3

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

doc/src/sgml/datatype.sgml

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.232 2008/11/09 00:28:34 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.233 2008/11/09 17:09:48 tgl Exp $ -->
22

33
<chapter id="datatype">
44
<title id="datatype-title">Data Types</title>
@@ -2413,13 +2413,26 @@ January 8 04:05:06 1999 PST
24132413
Internally <type>interval</> values are stored as months, days,
24142414
and seconds. This is done because the number of days in a month
24152415
varies, and a day can have 23 or 25 hours if a daylight savings
2416-
time adjustment is involved. Because intervals are usually created
2417-
from constant strings or <type>timestamp</> subtraction, this
2418-
storage method works well in most cases. Functions
2416+
time adjustment is involved. The months and days fields are integers
2417+
while the seconds field can store fractions. Because intervals are
2418+
usually created from constant strings or <type>timestamp</> subtraction,
2419+
this storage method works well in most cases. Functions
24192420
<function>justify_days</> and <function>justify_hours</> are
24202421
available for adjusting days and hours that overflow their normal
24212422
ranges.
24222423
</para>
2424+
2425+
<para>
2426+
In the verbose input format, and in some fields of the more compact
2427+
input formats, field values can have fractional parts; for example
2428+
<literal>'1.5 week'</> or <literal>'01:02:03.45'</>. Such input is
2429+
converted to the appropriate number of months, days, and seconds
2430+
for storage. When this would result in a fractional number of
2431+
months or days, the fraction is added to the lower-order fields
2432+
using the conversion factors 1 month = 30 days and 1 day = 24 hours.
2433+
For example, <literal>'1.5 month'</> becomes 1 month and 15 days.
2434+
Only seconds will ever be shown as fractional on output.
2435+
</para>
24232436
</sect2>
24242437

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

0 commit comments

Comments
 (0)