Skip to Main Content
SQL in a Nutshell
book

SQL in a Nutshell

by Kevin Kline
December 2000
Intermediate to advanced content levelIntermediate to advanced
224 pages
9h 52m
English
O'Reilly Media, Inc.
Content preview from SQL in a Nutshell

Name

SET TIME ZONE

Synopsis

The SET TIME ZONE statement changes the current session’s time zone if it needs to be different from the default time zone.

Vendor

Command

SQL Server

Not supported

MySQL

Not supported

Oracle

Not supported

PostgreSQL

Supported, with variations

SQL99 Syntax and Description

SET TIME ZONE {LOCAL | INTERVAL {+ | -}'00:00' HOUR TO MINUTE}

Like most SET commands, SET TIME ZONE can be executed only outside of an explicit transaction. The LOCAL clause resets the current-session time values to those of the default time zone for the server. Otherwise, an interval value can be set to increase (with +) or decrease (with -) over the default time.

PostgreSQL Syntax and Variations

SET TIME ZONE {'timezone' | LOCAL | DEFAULT 
| INTERVAL {+ | -}'00:00' HOUR TO MINUTE};

PostgreSQL allows a session’s time value to be set to the server default by using either the LOCAL or DEFAULT clause.

The value specified for time zone is dependent on the operating system. For example, `PST8PDT’ is a valid time zone for California on Linux systems, while `Europe/Rome’ is a valid time zone for Italy on Linux and other systems. If an invalid time zone is specified, the command sets the time zone to Greenwich Mean Time (GMT).

The time zone also may be set as an interval of the default server time zone.

Examples

In the following example, the time zone is advanced three hours over the current default time zone:

SET TIME ZONE INTERVAL +'03:00' HOUR TO MINUTE;

Next, the current time for the current ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

SQL in a Nutshell, 3rd Edition

SQL in a Nutshell, 3rd Edition

Kevin Kline

Publisher Resources

ISBN: 1565927443