1
1
<!--
2
- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.146 2004/06/16 01:26:35 tgl Exp $
2
+ $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.147 2004/08/10 00:55:02 tgl Exp $
3
3
-->
4
4
5
5
<chapter id="datatype">
@@ -1668,6 +1668,11 @@ SELECT b, char_length(b) FROM test2;
1668
1668
</tbody>
1669
1669
</tgroup>
1670
1670
</table>
1671
+
1672
+ <para>
1673
+ Refer to <xref linkend="datetime-appendix"> for a list of
1674
+ time zone names that are recognized for input.
1675
+ </para>
1671
1676
</sect3>
1672
1677
1673
1678
<sect3>
@@ -1687,9 +1692,11 @@ SELECT b, char_length(b) FROM test2;
1687
1692
1688
1693
<para>
1689
1694
Valid input for the time stamp types consists of a concatenation
1690
- of a date and a time, followed by an optional
1691
- <literal>AD</literal> or <literal>BC</literal>, followed by an
1692
- optional time zone. Thus
1695
+ of a date and a time, followed by an optional time zone,
1696
+ followed by an optional <literal>AD</literal> or <literal>BC</literal>.
1697
+ (Alternatively, <literal>AD</literal>/<literal>BC</literal> can appear
1698
+ before the time zone, but this is not the preferred ordering.)
1699
+ Thus
1693
1700
1694
1701
<programlisting>
1695
1702
1999-01-08 04:05:06
@@ -1798,17 +1805,7 @@ January 8 04:05:06 1999 PST
1798
1805
</indexterm>
1799
1806
1800
1807
<para>
1801
- The following <acronym>SQL</acronym>-compatible functions can be
1802
- used as date or time values for the corresponding data type:
1803
- <literal>CURRENT_DATE</literal>, <literal>CURRENT_TIME</literal>,
1804
- <literal>CURRENT_TIMESTAMP</literal>, <literal>LOCALTIME</literal>,
1805
- <literal>LOCALTIMESTAMP</literal>. The latter four accept an
1806
- optional precision specification. (See also <xref
1807
- linkend="functions-datetime-current">.)
1808
- </para>
1809
-
1810
- <para>
1811
- <productname>PostgreSQL</productname> also supports several
1808
+ <productname>PostgreSQL</productname> supports several
1812
1809
special date/time input values for convenience, as shown in <xref
1813
1810
linkend="datatype-datetime-special-table">. The values
1814
1811
<literal>infinity</literal> and <literal>-infinity</literal>
@@ -1874,6 +1871,18 @@ January 8 04:05:06 1999 PST
1874
1871
</tgroup>
1875
1872
</table>
1876
1873
1874
+ <para>
1875
+ The following <acronym>SQL</acronym>-compatible functions can also
1876
+ be used to obtain the current time value for the corresponding data
1877
+ type:
1878
+ <literal>CURRENT_DATE</literal>, <literal>CURRENT_TIME</literal>,
1879
+ <literal>CURRENT_TIMESTAMP</literal>, <literal>LOCALTIME</literal>,
1880
+ <literal>LOCALTIMESTAMP</literal>. The latter four accept an
1881
+ optional precision specification. (See also <xref
1882
+ linkend="functions-datetime-current">.) Note however that these are
1883
+ SQL functions and are <emphasis>not</> recognized as data input strings.
1884
+ </para>
1885
+
1877
1886
</sect3>
1878
1887
</sect2>
1879
1888
@@ -1985,12 +1994,12 @@ January 8 04:05:06 1999 PST
1985
1994
<para>
1986
1995
<type>interval</type> output looks like the input format, except
1987
1996
that units like <literal>century</literal> or
1988
- <literal>wek </literal> are converted to years and days and that
1997
+ <literal>week </literal> are converted to years and days and
1989
1998
<literal>ago</literal> is converted to an appropriate sign. In
1990
1999
ISO mode the output looks like
1991
2000
1992
2001
<programlisting>
1993
- <optional> <replaceable>quantity</> <replaceable>unit</> <optional> ... </> </> <optional> <replaceable>days</> </> <optional> <replaceable>hours</>:<replaceable>minutes</>:<replaceable>sekunden </> </optional>
2002
+ <optional> <replaceable>quantity</> <replaceable>unit</> <optional> ... </> </> <optional> <replaceable>days</> </> <optional> <replaceable>hours</>:<replaceable>minutes</>:<replaceable>seconds </> </optional>
1994
2003
</programlisting>
1995
2004
</para>
1996
2005
@@ -2017,19 +2026,13 @@ January 8 04:05:06 1999 PST
2017
2026
Time zones, and time-zone conventions, are influenced by
2018
2027
political decisions, not just earth geometry. Time zones around the
2019
2028
world became somewhat standardized during the 1900's,
2020
- but continue to be prone to arbitrary changes.
2021
- <productname>PostgreSQL</productname> uses your operating
2022
- system's underlying features to provide output time-zone
2023
- support, and these systems usually contain information for only
2024
- the time period 1902 through 2038 (corresponding to the full
2025
- range of conventional Unix system time).
2026
- <type>timestamp with time zone</type> and <type>time with time
2027
- zone</type> will use time zone
2028
- information only within that year range, and assume that times
2029
- outside that range are in <acronym>UTC</acronym>.
2030
- But since time zone support is derived from the underlying operating
2031
- system time-zone capabilities, it can handle daylight-saving time
2032
- and other special behavior.
2029
+ but continue to be prone to arbitrary changes, particularly with
2030
+ respect to daylight-savings rules.
2031
+ <productname>PostgreSQL</productname> currently supports daylight-savings
2032
+ rules over the time period 1902 through 2038 (corresponding to the full
2033
+ range of conventional Unix system time). Times outside that range are
2034
+ taken to be in <quote>standard time</> for the selected time zone, no
2035
+ matter what part of the year they fall in.
2033
2036
</para>
2034
2037
2035
2038
<para>
@@ -2044,8 +2047,8 @@ January 8 04:05:06 1999 PST
2044
2047
Although the <type>date</type> type
2045
2048
does not have an associated time zone, the
2046
2049
<type>time</type> type can.
2047
- Time zones in the real world can have no meaning unless
2048
- associated with a date as well as a time
2050
+ Time zones in the real world have little meaning unless
2051
+ associated with a date as well as a time,
2049
2052
since the offset may vary through the year with daylight-saving
2050
2053
time boundaries.
2051
2054
</para>
@@ -2054,8 +2057,8 @@ January 8 04:05:06 1999 PST
2054
2057
<listitem>
2055
2058
<para>
2056
2059
The default time zone is specified as a constant numeric offset
2057
- from <acronym>UTC</>. It is not possible to adapt to daylight-saving
2058
- time when doing date/time arithmetic across
2060
+ from <acronym>UTC</>. It is therefore not possible to adapt to
2061
+ daylight-saving time when doing date/time arithmetic across
2059
2062
<acronym>DST</acronym> boundaries.
2060
2063
</para>
2061
2064
</listitem>
@@ -2069,34 +2072,45 @@ January 8 04:05:06 1999 PST
2069
2072
recommend <emphasis>not</emphasis> using the type <type>time with
2070
2073
time zone</type> (though it is supported by
2071
2074
<productname>PostgreSQL</productname> for legacy applications and
2072
- for compatibility with other <acronym>SQL</acronym>
2073
- implementations). <productname>PostgreSQL</productname> assumes
2075
+ for compliance with the <acronym>SQL</acronym> standard).
2076
+ <productname>PostgreSQL</productname> assumes
2074
2077
your local time zone for any type containing only date or time.
2075
2078
</para>
2076
2079
2077
2080
<para>
2078
- All dates and times are stored internally in
2079
- <acronym>UTC</acronym>. Times are converted to local time
2080
- on the database server before being sent to the client,
2081
- hence by default are in the server time zone .
2081
+ All timezone-aware dates and times are stored internally in
2082
+ <acronym>UTC</acronym>. They are converted to local time
2083
+ in the zone specified by the <xref linkend="guc-timezone"> configuration
2084
+ parameter before being displayed to the client .
2082
2085
</para>
2083
2086
2084
2087
<para>
2085
- There are several ways to select the time zone used by the server:
2088
+ The <xref linkend="guc-timezone"> configuration parameter can
2089
+ be set in the file <filename>postgresql.conf</>, or in any of the
2090
+ other standard ways described in <xref linkend="runtime-config">.
2091
+ There are also several special ways to set it:
2086
2092
2087
2093
<itemizedlist>
2088
2094
<listitem>
2089
2095
<para>
2090
- The <envar>TZ</envar> environment variable on the server host
2091
- is used by the server as the default time zone, if no other is
2092
- specified.
2096
+ If <varname>timezone</> is not specified in
2097
+ <filename>postgresql.conf</> nor as a postmaster command-line switch,
2098
+ the server attempts to use the value of the <envar>TZ</envar>
2099
+ environment variable as the default time zone. If <envar>TZ</envar>
2100
+ is not defined or is not any of the time zone names known to
2101
+ <productname>PostgreSQL</productname>, the server attempts to
2102
+ determine the operating system's default time zone by checking the
2103
+ behavior of the C library function <literal>localtime()</>. The
2104
+ default time zone is selected as the closest match among
2105
+ <productname>PostgreSQL</productname>'s known time zones.
2093
2106
</para>
2094
2107
</listitem>
2095
2108
2096
2109
<listitem>
2097
2110
<para>
2098
- The <xref linkend="guc-timezone"> configuration parameter can
2099
- be set in the file <filename>postgresql.conf</>.
2111
+ The <acronym>SQL</acronym> command <command>SET TIME ZONE</command>
2112
+ sets the time zone for the session. This is an alternative spelling
2113
+ of <command>SET TIMEZONE TO</> with a more SQL-spec-compatible syntax.
2100
2114
</para>
2101
2115
</listitem>
2102
2116
@@ -2108,23 +2122,9 @@ January 8 04:05:06 1999 PST
2108
2122
command to the server upon connection.
2109
2123
</para>
2110
2124
</listitem>
2111
-
2112
- <listitem>
2113
- <para>
2114
- The <acronym>SQL</acronym> command <command>SET TIME ZONE</command>
2115
- sets the time zone for the session.
2116
- </para>
2117
- </listitem>
2118
2125
</itemizedlist>
2119
2126
</para>
2120
2127
2121
- <note>
2122
- <para>
2123
- If an invalid time zone is specified, the time zone becomes
2124
- <acronym>UTC</acronym> (on most systems anyway).
2125
- </para>
2126
- </note>
2127
-
2128
2128
<para>
2129
2129
Refer to <xref linkend="datetime-appendix"> for a list of
2130
2130
available time zones.
0 commit comments