Skip to content

Commit dd6073f

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 d6e98eb commit dd6073f

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
@@ -8082,10 +8082,11 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
80828082
</indexterm>
80838083

80848084
<para>
8085-
The <literal>AT TIME ZONE</literal> construct allows conversions
8086-
of time stamps to different time zones. <xref
8087-
linkend="functions-datetime-zoneconvert-table"/> shows its
8088-
variants.
8085+
The <literal>AT TIME ZONE</literal> converts time
8086+
stamp <emphasis>without time zone</emphasis> to/from
8087+
time stamp <emphasis>with time zone</emphasis>, and
8088+
<emphasis>time</emphasis> values to different time zones. <xref
8089+
linkend="functions-datetime-zoneconvert-table"/> shows its variants.
80898090
</para>
80908091

80918092
<table id="functions-datetime-zoneconvert-table">
@@ -8130,24 +8131,33 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
81308131

81318132
<para>
81328133
In these expressions, the desired time zone <replaceable>zone</replaceable> can be
8133-
specified either as a text string (e.g., <literal>'PST'</literal>)
8134+
specified either as a text string (e.g., <literal>'America/Los_Angeles'</literal>)
81348135
or as an interval (e.g., <literal>INTERVAL '-08:00'</literal>).
81358136
In the text case, a time zone name can be specified in any of the ways
81368137
described in <xref linkend="datatype-timezones"/>.
81378138
</para>
81388139

81398140
<para>
8140-
Examples (assuming the local time zone is <literal>PST8PDT</literal>):
8141+
Examples (assuming the local time zone is <literal>America/Los_Angeles</literal>):
81418142
<screen>
8142-
SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'MST';
8143+
SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'America/Denver';
81438144
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 19:38:40-08</computeroutput>
81448145

8145-
SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'MST';
8146+
SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'America/Denver';
81468147
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 18:38:40</computeroutput>
8148+
8149+
SELECT TIMESTAMP '2001-02-16 20:38:40-05' AT TIME ZONE 'Asia/Tokyo' AT TIME ZONE 'America/Chicago';
8150+
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 05:38:40</computeroutput>
81478151
</screen>
8148-
The first example takes a time stamp without time zone and interprets it as MST time
8149-
(UTC-7), which is then converted to PST (UTC-8) for display. The second example takes
8150-
a time stamp specified in EST (UTC-5) and converts it to local time in MST (UTC-7).
8152+
The first example adds a time zone to a value that lacks it, and
8153+
displays the value using the current <varname>TimeZone</varname>
8154+
setting. The second example shifts the time stamp with time zone value
8155+
to the specified time zone, and returns the value without a time zone.
8156+
This allows storage and display of values different from the current
8157+
<varname>TimeZone</varname> setting. The third example converts
8158+
Tokyo time to Chicago time. Converting <emphasis>time</emphasis>
8159+
values to other time zones uses the currently active time zone rules
8160+
since no date is supplied.
81518161
</para>
81528162

81538163
<para>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy