Book Contents

Book Index

Next Topic

Home

AT TIME ZONE

The AT TIME ZONE construct converts TIME and TIMEZONE types to different time zones.

Syntax

 

timestamp AT TIME ZONE zone

Semantics

 

timestamp

 

TIMESTAMP

converts UTC to local time in given time zone

TIMESTAMP WITH TIME ZONE

converts local time in given time zone to UTC

TIME WITH TIME ZONE

converts local time across time zones

zone

is the desired time zone specified either as a text string (for example: 'PST') or as an interval (for example: INTERVAL '-08:00'). In the text case, the available zone names are abbreviations.

Examples

The local time zone is PST8PDT.

SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'MST';

Result: 2001-02-16 19:38:40-05

SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'MST';

Result: 2001-02-16 18:38:40

The first example takes a zone-less time stamp and interprets it as MST time (UTC- 7) to produce a UTC time stamp, which is then rotated to PST (UTC-8) for display. The second example takes a time stamp specified in EST (UTC-5) and converts it to local time in MST (UTC-7).