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

Commit a704f83

Browse files
committed
docs: improve AT TIME ZONE description
The previous description was unclear. Also add a third example, change use of time zone acronyms to more verbose descriptions, and add a mention that using 'time' with AT TIME ZONE uses the current time zone rules. Backpatch-through: 9.3
1 parent f658235 commit a704f83

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

doc/src/sgml/func.sgml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7889,10 +7889,11 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
78897889
</indexterm>
78907890

78917891
<para>
7892-
The <literal>AT TIME ZONE</literal> construct allows conversions
7893-
of time stamps to different time zones. <xref
7894-
linkend="functions-datetime-zoneconvert-table"> shows its
7895-
variants.
7892+
The <literal>AT TIME ZONE</literal> converts time
7893+
stamp <emphasis>without time zone</emphasis> to/from
7894+
time stamp <emphasis>with time zone</emphasis>, and
7895+
<emphasis>time</emphasis> values to different time zones. <xref
7896+
linkend="functions-datetime-zoneconvert-table"> shows its variants.
78967897
</para>
78977898

78987899
<table id="functions-datetime-zoneconvert-table">
@@ -7937,24 +7938,33 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
79377938

79387939
<para>
79397940
In these expressions, the desired time zone <replaceable>zone</> can be
7940-
specified either as a text string (e.g., <literal>'PST'</literal>)
7941+
specified either as a text string (e.g., <literal>'America/Los_Angeles'</literal>)
79417942
or as an interval (e.g., <literal>INTERVAL '-08:00'</literal>).
79427943
In the text case, a time zone name can be specified in any of the ways
79437944
described in <xref linkend="datatype-timezones">.
79447945
</para>
79457946

79467947
<para>
7947-
Examples (assuming the local time zone is <literal>PST8PDT</>):
7948+
Examples (assuming the local time zone is <literal>America/Los_Angeles</literal>):
79487949
<screen>
7949-
SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'MST';
7950+
SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'America/Denver';
79507951
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 19:38:40-08</computeroutput>
79517952

7952-
SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'MST';
7953+
SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'America/Denver';
79537954
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 18:38:40</computeroutput>
7955+
7956+
SELECT TIMESTAMP '2001-02-16 20:38:40-05' AT TIME ZONE 'Asia/Tokyo' AT TIME ZONE 'America/Chicago';
7957+
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 05:38:40</computeroutput>
79547958
</screen>
7955-
The first example takes a time stamp without time zone and interprets it as MST time
7956-
(UTC-7), which is then converted to PST (UTC-8) for display. The second example takes
7957-
a time stamp specified in EST (UTC-5) and converts it to local time in MST (UTC-7).
7959+
The first example adds a time zone to a value that lacks it, and
7960+
displays the value using the current <varname>TimeZone</varname>
7961+
setting. The second example shifts the time stamp with time zone value
7962+
to the specified time zone, and returns the value without a time zone.
7963+
This allows storage and display of values different from the current
7964+
<varname>TimeZone</varname> setting. The third example converts
7965+
Tokyo time to Chicago time. Converting <emphasis>time</emphasis>
7966+
values to other time zones uses the currently active time zone rules
7967+
since no date is supplied.
79587968
</para>
79597969

79607970
<para>

0 commit comments

Comments
 (0)