Month Day [ Hour : Minute : Second ] Year [AD,BC] [ Timezone ]
...
...
@@ -1003,62 +1013,65 @@ where
Minute is 00, 01, ..., 59
Second is 00, 01, ..., 59 (60 for leap second)
Timezone is 3 characters or ISO offset to GMT
</ProgramListing>
</programlisting>
</para>
<Para>
<para>
Valid dates are from Nov 13 00:00:00 4013 BC GMT to far into the future.
Timezones are either three characters (e.g. "GMT" or "PST") or ISO-compatible
offsets to GMT (e.g. "-08" or "-08:00" when in Pacific Standard Time).
Dates are stored internally in Greenwich Mean Time. Input and output routines
translate time to the local time zone of the server.
</Para>
</para></sect2>
<Sect2>
<Title><Type>timespan</Type></Title>
<sect2>
<title><type>timespan</type></title>
<Para>
<para>
General-use time span is input using a wide range of
syntaxes, including ISO-compatible, <acronym>SQL</acronym>-compatible,
traditional
<ProductName>Postgres</ProductName> (see section on "relative time")
<productname>Postgres</productname> (see section on "relative time")
and other permutations of time span. Output formats can be ISO-compatible,
<acronym>SQL</acronym>-compatible, or traditional
<ProductName>Postgres</ProductName>,
with the default set to be <ProductName>Postgres</ProductName>-compatible.
<productname>Postgres</productname>,
with the default set to be <productname>Postgres</productname>-compatible.
Months and years are a "qualitative" time interval, and are stored separately
from the other "quantitative" time intervals such as day or hour.
For date arithmetic,
the qualitative time units are instantiated in the context of the
relevant date or time.
</para>
<Para>
<para>
Time span is specified with the following syntax:
<ProgramListing>
<programlisting>
Quantity Unit [Quantity Unit...] [Direction]
@ Quantity Unit [Direction]
where
Quantity is ..., `-1', `0', `1', `2', ...
Unit is `second', `minute', `hour', `day', `week', `month', `year',
'decade', 'century', millenium', or abbreviations or plurals of these units.
Direction is `ago'.
</ProgramListing>
</Para>
</Sect2>
<Sect2>
<Title>abstime</Title>
<Para>
Absolute time (<type>abstime</type>) is a limited-range (+/- 68 years) and
limited-precision (1 sec)
date data type. <Type>datetime</Type> may be preferred, since it
covers a larger range with greater precision.
<Para>
Quantity is ..., <literal>-1</literal>, <literal>0</literal>, <literal>1</literal>, <literal>2</literal>, ...
Unit is <literal>second</literal>, <literal>minute</literal>, <literal>hour</literal>, <literal>day</literal>, <literal>week</literal>, <literal>month</literal>, <literal>year</literal>,
<literal>decade</literal>, <literal>century</literal>, <literal>millenium</literal>, or abbreviations or plurals of these units.
Direction is <literal>ago</literal>.
</programlisting>
</para>
</sect2>
<sect2>
<title>abstime</title>
<para>
Absolute time (<type>abstime</type>) is a limited-range (+/- 68 years) and
limited-precision (1 sec)
date data type. <type>datetime</type> may be preferred, since it
covers a larger range with greater precision.
</para>
<para>
Absolute time is specified using the following syntax:
<ProgramListing>
<programlisting>
Month Day [ Hour : Minute : Second ] Year [ Timezone ]
where
Month is Jan, Feb, ..., Dec
...
...
@@ -1067,311 +1080,315 @@ where
Minute is 00, 01, ..., 59
Second is 00, 01, ..., 59
Year is 1901, 1902, ..., 2038
</ProgramListing>
</Para>
</programlisting>
</para>
<Para>
Valid dates are from Dec 13 20:45:53 1901 GMT to Jan 19 03:14:04
2038 GMT.
<para>
Valid dates are from <literal>Dec 13 20:45:53 1901 GMT</literal>
to <literal>Jan 19 03:14:04 2038 GMT</literal>.
<note>
<title>Historical Note</title>
<para>
As of Version 3.0, times are no longer read and written
using Greenwich Mean Time; the input and output routines default to
the local time zone.
the local time zone.</para>
</note>
All special values allowed for <Type>datetime</Type> are also
All special values allowed for <type>datetime</type> are also
allowed for "absolute time".
</Para>
</para>
</Sect2>
</sect2>
<Sect2>
<Title>reltime</Title>
<sect2>
<title>reltime</title>
<Para>
Relative time <Type>reltime</Type> is a limited-range (+/- 68 years)
<para>
Relative time <type>reltime</type> is a limited-range (+/- 68 years)
and limited-precision (1 sec) time span data type.
<Type>timespan</Type> should be preferred, since it
<type>timespan</type> should be preferred, since it
covers a larger range with greater precision and, more importantly,
can distinguish between
relative units (months and years) and quantitative units (days, hours, etc).
Instead, reltime
must force months to be exactly 30 days, so time arithmetic does not
always work as expected.
For example, adding one reltime year to abstime today does not
For example, adding one reltime <literal>year</literal> to abstime <literal>today</literal> does not
produce today's date one year from
now, but rather a date 360 days from today.
</Para>
</para>
<Para>
<Type>reltime</Type> shares input and output routines with the other
<para>
<type>reltime</type> shares input and output routines with the other
time span types.
The section on <Type>timespan</Type> covers this in more detail.
</Para>
The section on <type>timespan</type> covers this in more detail.
</para>
</Sect2>
</sect2>
<Sect2>
<Title><Type>timestamp</Type></Title>
<sect2>
<title><type>timestamp</type></title>
<Para>
<para>
This is currently a limited-range absolute time which closely resembles the
abstime
data type. It shares the general input parser with the other date/time types.
In future releases this type will absorb the capabilities of the
<Type>datetime</Type> type
<type>datetime</type> type
and will move toward <acronym>SQL92</acronym> compliance.
</Para>
</para>
<Para>
<Type>timestamp</Type> is specified using the same syntax as for
<Type>datetime</Type>.
</Para>
</Sect2>
<para>
<type>timestamp</type> is specified using the same syntax as for
<type>datetime</type>.
</para>
</sect2>
<Sect2>
<Title><Type>interval</Type></Title>
<sect2>
<title><type>interval</type></title>
<Para>
<Type>interval</Type> is an <Acronym>SQL92</Acronym> data type which is
currently mapped to the <Type>timespan</Type>
<ProductName>Postgres</ProductName> data type.
</Para>
</Sect2>
<para>
<type>interval</type> is an <acronym>SQL92</acronym> data type which is
currently mapped to the <type>timespan</type>
<productname>Postgres</productname> data type.
</para>
</sect2>
<Sect2>
<Title>tinterval</Title>
<sect2>
<title>tinterval</title>
<Para>
<para>
Time ranges are specified as:
<ProgramListing>
<programlisting>
[ 'abstime' 'abstime']
where
abstime is a time in the absolute time format.
</ProgramListing>
</programlisting>
Special abstime values such as
`current', `infinity' and `-infinity' can be used.
</Para>
<literal>current', <literal>infinity' and <literal>-infinity' can be used.</literal></literal></literal>
</para></sect2>
</Sect1>
</sect1>
<Sect1>
<Title>Boolean Type</Title>
<sect1>
<title>Boolean Type</title>
<Para>
<ProductName>Postgres</ProductName> supports <Type>bool</Type> as
the <Acronym>SQL3</Acronym> boolean type.
<Type>bool</Type> can have one of only two states: 'true' or 'false'.
<para>
<productname>Postgres</productname> supports <type>bool</type> as
the <acronym>SQL3</acronym> boolean type.
<type>bool</type> can have one of only two states: 'true' or 'false'.
A third state, 'unknown', is not
implemented and is not suggested in <Acronym>SQL3</Acronym>;
<Acronym>NULL</Acronym> is an
effective substitute. <Type>bool</Type> can be used in any boolean expression,
implemented and is not suggested in <acronym>SQL3</acronym>;
<acronym>NULL</acronym> is an
effective substitute. <type>bool</type> can be used in any boolean expression,
and boolean expressions
always evaluate to a result compatible with this type.