11<!--
2- $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.108 2002/11/15 03:11:15 momjian Exp $
2+ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.109 2002/11/21 23:31:20 tgl Exp $
33-->
44
55 <chapter id="datatype">
@@ -1569,19 +1569,31 @@ SELECT b, char_length(b) FROM test2;
15691569 <secondary>data type</secondary>
15701570 </indexterm>
15711571
1572+ <indexterm>
1573+ <primary>timestamp with time zone</primary>
1574+ <secondary>data type</secondary>
1575+ </indexterm>
1576+
15721577 <indexterm>
15731578 <primary>timestamp without time zone</primary>
15741579 <secondary>data type</secondary>
15751580 </indexterm>
15761581
15771582 <para>
1578- Time stamp types exist as <type>timestamp [
1579- (<replaceable>p</replaceable>) ]</type>, <type>timestamp [
1583+ The time stamp types are <type>timestamp [
15801584 (<replaceable>p</replaceable>) ] without time zone</type> and
1581- <type>timestamp [ (<replaceable>p</replaceable>) ] without time
1582- zone</type>. A plain <type>timestamp</type> is equivalent to
1583- <type>timestamp without timezone</type>.
1585+ <type>timestamp [ (<replaceable>p</replaceable>) ] with time
1586+ zone</type>. Writing just <type>timestamp</type> is equivalent to
1587+ <type>timestamp without time zone</type>.
1588+ </para>
1589+
1590+ <note>
1591+ <para>
1592+ Prior to <productname>PostgreSQL</productname> 7.3, writing just
1593+ <type>timestamp</type> was equivalent to <type>timestamp with time
1594+ zone</type>. This was changed for SQL spec compliance.
15841595 </para>
1596+ </note>
15851597
15861598 <para>
15871599 Valid input for the time stamp types consists of a concatenation
@@ -1615,11 +1627,38 @@ January 8 04:05:06 1999 PST
16151627
16161628 <para>
16171629 For <type>timestamp without time zone</type>, any explicit time
1618- zone specified in the input is silently swallowed . That is, the
1630+ zone specified in the input is silently ignored . That is, the
16191631 resulting date/time value is derived from the explicit date/time
16201632 fields in the input value, and is not adjusted for time zone.
16211633 </para>
16221634
1635+ <para>
1636+ For <type>timestamp with time zone</type>, the internally stored
1637+ value is always in UTC (GMT). An input value that has an explicit
1638+ time zone specified is converted to UTC using the appropriate offset
1639+ for that time zone. If no time zone is stated in the input string,
1640+ then it is assumed to be in the time zone indicated by the system's
1641+ <varname>TimeZone</> parameter, and is converted to UTC using the
1642+ offset for the <varname>TimeZone</> zone.
1643+ </para>
1644+
1645+ <para>
1646+ When a <type>timestamp with time
1647+ zone</type> value is output, it is always converted from UTC to the
1648+ current <varname>TimeZone</> zone, and displayed as local time in that
1649+ zone. To see the time in another time zone, either change
1650+ <varname>TimeZone</> or use the <literal>AT TIME ZONE</> construct
1651+ (see <xref linkend="functions-datetime-zoneconvert">).
1652+ </para>
1653+
1654+ <para>
1655+ Conversions between <type>timestamp without time zone</type> and
1656+ <type>timestamp with time zone</type> normally assume that the
1657+ <type>timestamp without time zone</type> value should be taken or given
1658+ as <varname>TimeZone</> local time. A different zone reference can
1659+ be specified for the conversion using <literal>AT TIME ZONE</>.
1660+ </para>
1661+
16231662 <table tocentry="1" id="datatype-timezone-table">
16241663 <title>Time Zone Input</title>
16251664 <tgroup cols="2">
@@ -1707,24 +1746,28 @@ January 8 04:05:06 1999 PST
17071746 <para>
17081747 The following <acronym>SQL</acronym>-compatible functions can be
17091748 used as date or time
1710- input for the corresponding data type: <literal>CURRENT_DATE</literal>,
1749+ values for the corresponding data type: <literal>CURRENT_DATE</literal>,
17111750 <literal>CURRENT_TIME</literal>,
17121751 <literal>CURRENT_TIMESTAMP</literal>. The latter two accept an
1713- optional precision specification. (See also <xref linkend="functions-datetime">.)
1752+ optional precision specification. (See also <xref linkend="functions-datetime-current ">.)
17141753 </para>
17151754
17161755 <para>
17171756 <productname>PostgreSQL</productname> also supports several
1718- special constants for convenience, shown in <xref
1719- linkend="datatype-datetime-special-table">.
1757+ special date/time input values for convenience, as shown in <xref
1758+ linkend="datatype-datetime-special-table">. The values
1759+ <literal>infinity</literal> and <literal>-infinity</literal>
1760+ are specially represented inside the system and will be displayed
1761+ the same way; but the others are simply notational shorthands
1762+ that will be converted to ordinary date/time values when read.
17201763 </para>
17211764
17221765 <table id="datatype-datetime-special-table">
1723- <title>Special Date/Time Constants </title>
1766+ <title>Special Date/Time Inputs </title>
17241767 <tgroup cols="2">
17251768 <thead>
17261769 <row>
1727- <entry>Constant </entry>
1770+ <entry>Input string </entry>
17281771 <entry>Description</entry>
17291772 </row>
17301773 </thead>
@@ -1735,15 +1778,13 @@ January 8 04:05:06 1999 PST
17351778 </row>
17361779 <row>
17371780 <entry><literal>infinity</literal></entry>
1738- <entry>later than other valid times</entry>
1781+ <entry>later than all other timestamps (not available for
1782+ type <type>date</>)</entry>
17391783 </row>
17401784 <row>
17411785 <entry><literal>-infinity</literal></entry>
1742- <entry>earlier than other valid times</entry>
1743- </row>
1744- <row>
1745- <entry><literal>invalid</literal></entry>
1746- <entry>illegal entry</entry>
1786+ <entry>earlier than all other timestamps (not available for
1787+ type <type>date</>)</entry>
17471788 </row>
17481789 <row>
17491790 <entry><literal>now</literal></entry>
@@ -1962,13 +2003,21 @@ January 8 04:05:06 1999 PST
19622003 </para>
19632004
19642005 <para>
1965- There are several ways to affect the time- zone behavior :
2006+ There are several ways to select the time zone used by the server :
19662007
19672008 <itemizedlist>
19682009 <listitem>
19692010 <para>
19702011 The <envar>TZ</envar> environment variable on the server host
1971- is used by the server as the default time zone.
2012+ is used by the server as the default time zone, if no other is
2013+ specified.
2014+ </para>
2015+ </listitem>
2016+
2017+ <listitem>
2018+ <para>
2019+ The <varname>timezone</varname> configuration parameter can be
2020+ set in <filename>postgresql.conf</>.
19722021 </para>
19732022 </listitem>
19742023
@@ -1987,18 +2036,6 @@ January 8 04:05:06 1999 PST
19872036 sets the time zone for the session.
19882037 </para>
19892038 </listitem>
1990-
1991- <listitem>
1992- <para>
1993- The construct
1994- <programlisting>
1995- <replaceable>timestamp</replaceable> AT TIME ZONE '<replaceable>zone</replaceable>'
1996- </programlisting>
1997- where <replaceable>zone</replaceable> can be specified as a
1998- text time zone (e.g., <literal>'PST'</literal>) or as an
1999- interval (e.g., <literal>INTERVAL '-08:00'</literal>).
2000- </para>
2001- </listitem>
20022039 </itemizedlist>
20032040 </para>
20042041
0 commit comments