// dates & times reference

SQL NEW_TIME function

Converts a DATE between a hard-coded list of GMT and North American zone abbreviations (EST, PST, HST...); it predates Oracle's real time zone types.

Категория
Dates & times
Returns
date
In this category
107 of 121

Синтаксис

NEW_TIME(date, 'from_zone', 'to_zone')

Поддержка движка

ДвижокSupportЗаметки
SQL Server Different name or syntax AT TIME ZONE chains
PostgreSQL Different name or syntax ts AT TIME ZONE chains
MySQL Different name or syntax CONVERT_TZ with names or offsets
SQLite Not built in нет
Oracle Да this, or TIMESTAMP WITH TIME ZONE arithmetic

Примеры

Oracle

SELECT NEW_TIME(TO_DATE('2026-08-01 14:30', 'YYYY-MM-DD HH24:MI'), 'PST', 'GMT') FROM dual;  -- 2026-08-01 22:30

Oracle

SELECT NEW_TIME(SYSDATE, 'EST', 'CET') FROM dual;  -- ORA-01857: not a valid time zone

Полезно знать

  • The zone list is fixed: AST/ADT, BST/BDT (Bering, not British), CST/CDT, EST/EDT, GMT, HST/HDT, MST/MDT, NST (Newfoundland), PST/PDT and YST/YDT. Anything else, CET included, raises ORA-01857.
  • It works on DATE, which has second precision: sub-second and historical DST rules are silently out of scope; modern code should use TIMESTAMP WITH TIME ZONE and AT TIME ZONE.
  • DST handling is naive: pass 'EST' and you get standard time all year; pass 'EDT' and you claim daylight all year. NEW_TIME never decides for you.

Questions about NEW_TIME

Is NEW_TIME deprecated?

Not formally, but superseded: FROM_TZ plus AT TIME ZONE on TIMESTAMP WITH TIME ZONE covers arbitrary IANA zones with real DST history. Keep NEW_TIME for legacy column data only.

What is the PostgreSQL equivalent?

ts AT TIME ZONE 'America/Los_Angeles' AT TIME ZONE 'UTC': any IANA zone, from the tz database PostgreSQL ships with (or the OS copy, depending on how it was built).

Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.

Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, Oracle.

// fewer lookups

Functions your engine actually has

SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.