---
title: "Date/time types: DATE, TIME, TIMESTAMP, DATETIME and time zones"
description: "CoraDB date and time types DATE, TIME, TIMESTAMP and DATETIME: ranges, literals, string conversion and the time zone types."
url: "https://www.coradb.ai/manual/sql/datatype_datetime.html"
markdown_url: "https://www.coradb.ai/manual/markdown/sql/datatype_datetime.md"
product: "CoraDB"
version: "1.0"
keywords: "coradb date, time, timestamp, datetime, timestamptz, timestampltz, datetimetz, datetimeltz, time zone, date literal, string to date, iana time zone"
---

# Date/time types: DATE, TIME, TIMESTAMP, DATETIME and time zones

## Date/time types

Date/time types store a date, a time of day, or both. CoraDB supports the following types:

| Type | Bytes | Min | Max | Notes |
|---|---|---|---|---|
| **DATE** | 4 | 0001-01-01 | 9999-12-31 | |
| **TIME** | 4 | 00:00:00 | 23:59:59 | |
| **TIMESTAMP** | 4 | 1970-01-01 00:00:01 UTC | 2038-01-19 03:14:07 UTC | Stored as seconds since the Unix epoch, shown in the session time zone. |
| **DATETIME** | 8 | 0001-01-01 00:00:00.000 | 9999-12-31 23:59:59.999 | Millisecond precision. |
| **TIMESTAMPLTZ** | 4 | As **TIMESTAMP** | As **TIMESTAMP** | **TIMESTAMP WITH LOCAL TIME ZONE** |
| **TIMESTAMPTZ** | 8 | As **TIMESTAMP** | As **TIMESTAMP** | **TIMESTAMP WITH TIME ZONE** |
| **DATETIMELTZ** | 8 | 0001-01-01 00:00:00.000 UTC | 9999-12-31 23:59:59.999 UTC | **DATETIME WITH LOCAL TIME ZONE** |
| **DATETIMETZ** | 12 | 0001-01-01 00:00:00.000 UTC | 9999-12-31 23:59:59.999 UTC | **DATETIME WITH TIME ZONE** |

In the e-commerce sample database, `orders.order_date` and `orders.shipped_date` are **DATE** columns, and the `since` property of the graph edges (for example `likes.since`) is **DATETIME**.

**Range and resolution**

- Times use the 24-hour clock and dates follow the Gregorian calendar. A value that does not exist in either is rejected.
- **TIMESTAMP** covers 1970-01-01 00:00:01 to 2038-01-19 03:14:07 UTC. In a session at UTC+9 that is 1970-01-01 09:00:01 to 2038-01-19 12:14:07 local time. Use **DATETIME** for values outside this range or when you need milliseconds.
- For the time zone types the limits apply to the value converted to UTC, so the local limits depend on the time zone.
- **TIME** and **TIMESTAMP** have a resolution of one second, **DATE** of one day, **DATETIME** of one millisecond. Extra precision in the input is dropped.

**Two-digit years**

A two-digit year from 00 to 69 means 2000–2069, and 70 to 99 means 1970–1999. A year written with one, three or four digits is taken as is.

```sql
SELECT DATE'00-10-31' AS a, DATE'70-10-31' AS b, DATE'0070-10-31' AS c;
```

| a | b | c |
|---|---|---|
| 2000-10-31 | 1970-10-31 | 0070-10-31 |

**Zero dates**

Zero is not a valid year, month or day, so `DATE'0000-10-31'` is an error (`Invalid date`). As an exception, a value whose fields are *all* zero is accepted: `DATE'0000-00-00'`, `TIMESTAMP'0000-00-00 00:00:00'`, `DATETIME'0000-00-00 00:00:00'` and the same for the time zone types. For **TIMESTAMP**, 1970-01-01 00:00:00 UTC is the same value as `TIMESTAMP'0000-00-00 00:00:00'`.

- Date/time functions given an all-zero argument either return **NULL** or raise an error, depending on the system parameter [return_null_on_function_errors](https://www.coradb.ai/manual/admin/config_sql.html#return_null_on_function_errors) (default `no`: error).
- Java cannot represent an all-zero date. JDBC handles it according to the `zeroDateTimeBehavior` connection property (raise an exception, return **NULL**, or return the minimum value); see [Configuration connection](https://www.coradb.ai/manual/api/jdbc.html#configuration-connection).

**Display format**

The result tables in this manual show dates and times in ISO form (`2008-10-31`, `13:15:45`, `2008-10-31 13:15:45`). CoraDB's own text form, used by corasql and by `CAST(... AS STRING)`, is `MM/DD/YYYY` for dates and `hh:mi:ss AM|PM` for times, for example `01:15:45 PM 10/31/2008`. Drivers return native date/time values that your application formats. Use [TO_CHAR](https://www.coradb.ai/manual/sql/function/typecast_fn.html#fn-to_char) or [DATE_FORMAT](https://www.coradb.ai/manual/sql/function/typecast_fn.html#date_format) to choose a format in SQL.

When the system parameter **intl_date_lang** is set, [TO_DATE](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_date), [TO_TIME](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_time), [TO_DATETIME](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_datetime), [TO_TIMESTAMP](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_timestamp), [DATE_FORMAT](https://www.coradb.ai/manual/sql/function/typecast_fn.html#date_format), [TIME_FORMAT](https://www.coradb.ai/manual/sql/function/typecast_fn.html#time_format), [TO_CHAR](https://www.coradb.ai/manual/sql/function/typecast_fn.html#fn-to_char) and [STR_TO_DATE](https://www.coradb.ai/manual/sql/function/typecast_fn.html#str_to_date) read and write month and day names in that locale. See [Statement/type-related parameters](https://www.coradb.ai/manual/admin/config_sql.html#statementtype-related-parameters).

**Explicit conversion**

[CAST](https://www.coradb.ai/manual/sql/function/typecast_fn.html#cast) converts between date/time types that share a field:

| From \ to | DATE | TIME | DATETIME | TIMESTAMP |
|---|---|---|---|---|
| **DATE** | — | no | yes | yes |
| **TIME** | no | — | no | no |
| **DATETIME** | yes | yes | — | yes |
| **TIMESTAMP** | yes | yes | yes | — |

The time zone types follow the rules of their base type. Converting a **DATE** to **DATETIME** or **TIMESTAMP** sets the time to midnight; converting to **DATE** or **TIME** drops the other part:

```sql
SELECT CAST(DATE'2011-04-20' AS DATETIME) AS a, CAST(DATETIME'2011-04-20 09:10:15.359' AS DATE) AS b, CAST(DATETIME'2011-04-20 09:10:15.359' AS TIME) AS c;
```

| a | b | c |
|---|---|---|
| 2011-04-20 00:00:00.000 | 2011-04-20 | 09:10:15 |

`CAST(DATE'2011-04-20' AS TIME)` fails with `Cannot coerce date '2011-04-20' to type time`, and `CAST(TIME'09:10:15' AS DATETIME)` with `Casting time '09:10:15' to type datetime is not supported`. For implicit conversions see [Implicit type conversion](https://www.coradb.ai/manual/sql/datatype.html#implicit-type-conversion) and [Arithmetic operations and type casting of DATE/TIME data types](https://www.coradb.ai/manual/sql/function/arithmetic_op.html#arithmetic-operations-and-type-casting-of-datetime-data-types).

> **Note:**
> For the literal syntax of all date/time types, including the time zone types, see [Date/time literals](https://www.coradb.ai/manual/sql/literal.html#datetime).


### DATE

**DATE** stores a year, month and day, from 0001-01-01 to 9999-12-31.

```sql
DATE'mm/dd[/yyyy]'
DATE'[yyyy-]mm-dd'
```

- All fields are integers. If the year is omitted, the current year is used.
- [TO_DATE](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_date) converts a string in any format to a **DATE**.
- A **DEFAULT** value can be declared for a column of this type, for example `DEFAULT SYS_DATE`.

```sql
SELECT DATE'2008-10-31' AS a, DATE'10/31/2008' AS b, DATE'0000-00-00' AS c;
```

| a | b | c |
|---|---|---|
| 2008-10-31 | 2008-10-31 | 0000-00-00 |

`DATE'10/31'` is October 31 of the current year.

### TIME

**TIME** stores an hour, minute and second, from 00:00:00 to 23:59:59.

```sql
TIME'hh:mi[:ss] [AM | PM]'
```

- All fields are integers. If the seconds are omitted they are 0.
- Both 12-hour and 24-hour input is accepted. A 24-hour value may carry **PM** when it agrees with it (`13:15:45 PM`), but `TIME'13:15:45 AM'` is an error (`Invalid time`).
- [TO_TIME](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_time) converts a string in any format to a **TIME**.
- A **DEFAULT** value can be declared for a column of this type.

```sql
SELECT TIME'00:00:00' AS a, TIME'1:15' AS b, TIME'13:15:45' AS c, TIME'01:15:45 PM' AS d;
```

| a | b | c | d |
|---|---|---|---|
| 00:00:00 | 01:15:00 | 13:15:45 | 13:15:45 |

### TIMESTAMP

**TIMESTAMP** stores a date and a time to the second, from 1970-01-01 00:00:01 to 2038-01-19 03:14:07 UTC. The value is kept as seconds since the Unix epoch and shown in the session time zone.

```sql
TIMESTAMP'hh:mi[:ss] [AM|PM] mm/dd[/yyyy]'
TIMESTAMP'hh:mi[:ss] [AM|PM] [yyyy-]mm-dd'
TIMESTAMP'mm/dd[/yyyy] hh:mi[:ss] [AM|PM]'
TIMESTAMP'[yyyy-]mm-dd hh:mi[:ss] [AM|PM]'
```

- The time can come before or after the date. If the year is omitted, the current year is used; if the time is omitted, it is midnight.
- `SYS_TIMESTAMP` (also `SYSTIMESTAMP`, `CURRENT_TIMESTAMP`) returns the current timestamp, for example as a column **DEFAULT**.
- [TIMESTAMP](https://www.coradb.ai/manual/sql/function/datetime_fn.html#timestamp) and [TO_TIMESTAMP](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_timestamp) convert strings to **TIMESTAMP**.
- A value outside the range is an error: `TIMESTAMP'2099-10-31 01:15:45 PM'` fails with `Invalid utime`.

```sql
SELECT TIMESTAMP'10/31/2008' AS a, TIMESTAMP'13:15:45 10/31/2008' AS b, TIMESTAMP'01:15:45 PM 2008-10-31' AS c, TIMESTAMP'2008-10-31 01:15:45 PM' AS d;
```

| a | b | c | d |
|---|---|---|---|
| 2008-10-31 00:00:00 | 2008-10-31 13:15:45 | 2008-10-31 13:15:45 | 2008-10-31 13:15:45 |

### DATETIME

**DATETIME** stores a date and a time to the millisecond, from 0001-01-01 00:00:00.000 to 9999-12-31 23:59:59.999. It does not depend on the session time zone.

```sql
DATETIME'hh:mi[:ss[.msec]] [AM|PM] mm/dd[/yyyy]'
DATETIME'hh:mi[:ss[.msec]] [AM|PM] [yyyy-]mm-dd'
DATETIME'mm/dd[/yyyy] hh:mi[:ss[.msec]] [AM|PM]'
DATETIME'[yyyy-]mm-dd hh:mi[:ss[.msec]] [AM|PM]'
```

- The time can come before or after the date. If the year is omitted, the current year is used; if the time is omitted, it is midnight.
- `SYS_DATETIME` (also `SYSDATETIME`, [CURRENT_DATETIME](https://www.coradb.ai/manual/sql/function/datetime_fn.html#fn-current_datetime), [NOW](https://www.coradb.ai/manual/sql/function/datetime_fn.html#fn-now)) returns the current date and time, for example as a column **DEFAULT**.
- [TO_DATETIME](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_datetime) converts a string in any format to **DATETIME**.

```sql
SELECT DATETIME'10/31/2008' AS a, DATETIME'13:15:45 10/31/2008' AS b, DATETIME'2008-10-31 13:15:45.123' AS c, DATETIME'2099-10-31 01:15:45 PM' AS d;
```

| a | b | c | d |
|---|---|---|---|
| 2008-10-31 00:00:00.000 | 2008-10-31 13:15:45.000 | 2008-10-31 13:15:45.123 | 2099-10-31 13:15:45.000 |


### Converting strings to date/time values


#### Recommended formats

When you convert a string with [CAST](https://www.coradb.ai/manual/sql/function/typecast_fn.html#cast), or with [TO_DATE](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_date), [TO_TIME](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_time), [TO_DATETIME](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_datetime) or [TO_TIMESTAMP](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_timestamp) without a format argument, write the string in one of these forms. They do not depend on the database locale.

| Type | Formats |
|---|---|
| **DATE** | `YYYY-MM-DD`, `MM/DD/YYYY` |
| **TIME** | `HH:MI:SS [AM\|PM]` |
| **DATETIME** | `YYYY-MM-DD HH:MI:SS[.msec] [AM\|PM]`, `MM/DD/YYYY HH:MI:SS[.msec] [AM\|PM]`, or the time first: `HH:MI:SS[.msec] [AM\|PM] YYYY-MM-DD` |
| **TIMESTAMP** | As **DATETIME**, without milliseconds |

For example, `WHERE order_date >= '2025-12-01'` compares the **DATE** column with a date, because the string is converted to **DATE**.

#### Other accepted formats

**CAST** also accepts the following shorter forms.

**DATE strings**

- `[year sep] month sep day`: `2011-04-20`, or `04-20` for April 20 of the current year.
- With `/` as the separator the order is `month/day[/year]`: `04/20/2011`, `04/20`.
- Without separators: `YYYYMMDD`, `YYMMDD`, `YMMDD`, `MMDD` or `MDD`. The day always has two digits: `20110420` and `110420` are April 20, 2011; `420` is April 20 of the current year.

**TIME strings**

- `[hour]:min[:[sec]][.[msec]] [AM|PM]`: `09:10:15`, `09:10`, or `:10` (00:10:00). Milliseconds are accepted and dropped.
- Without separators, the digits are read from the right as seconds, minutes and hours: `91015` is 09:10:15, `1015` is 00:10:15, and `15` or `10` is that many seconds.
- A full date and time without separators (`20110420091015`) gives the time part.

**DATETIME strings**

- A date as above followed by an hour and optional minutes, seconds and milliseconds: `2011-04-20 09`, `04/20/2011 09`, `04-20 09`.
- Without separators: `YYMMDDHHMI[SS[.msec]]` or `YYYYMMDDHHMISS[.msec]`, and `YYMMDDH` when the hour has one digit (`1104209` is 2011-04-20 09:00). The digits are matched to the patterns by length, so `201104200910.359` (12 digits) is read as `YYMMDDHHMISS`, that is 2020-11-04 20:09:10.359.
- Time first, then date: `09:10:15.359 am 2011-04-20`, `:10 04/20`, `09 04-20`. In this form the time separator is always `:` and the date separator is `-` (`yyyy-mm-dd`) or `/` (`mm/dd/yyyy`).

**Rules**

- Milliseconds (*msec*) are kept only by **DATETIME**; digits after the third are ignored. **DATE**, **TIME** and **TIMESTAMP** drop them.
- A date string without separators, or with any non-alphanumeric separator, is accepted, but the same separator must be used throughout. The date and the time are separated by a space.
- The year can be omitted wherever the format allows; the current year is used. Two-digit years follow the 1970–2069 rule above.
- Converting a date-only string to **DATETIME** sets the time to midnight. Converting a date-and-time string to **DATE** or **TIME** keeps only that part, but the other part must still be valid.
- **AM**/**PM** must follow the time, separated by a space. The English markers are always accepted, as well as those of the server locale.

```sql
SELECT CAST('91015' AS TIME) AS a, CAST('110420091035.359' AS DATETIME) AS b, CAST('110420091035.359' AS TIMESTAMP) AS c, CAST('20110420' AS DATE) AS d, CAST('2011-04-20 09:10:15' AS TIME) AS e;
```

| a | b | c | d | e |
|---|---|---|---|---|
| 09:10:15 | 2011-04-20 09:10:35.359 | 2011-04-20 09:10:35 | 2011-04-20 | 09:10:15 |


## Date/time types with time zone

The time zone types carry time zone information in addition to the date and time. A time zone is written either as an IANA region name, optionally followed by the daylight-saving abbreviation (`Europe/Bucharest`, `Europe/Bucharest EEST`), or as an offset from UTC (`+09:00`).

- **TZ** types (**DATETIMETZ**, **TIMESTAMPTZ**, also written *type* `WITH TIME ZONE`) store the value in UTC together with its time zone (the one written in the value, or the session time zone). They take 4 bytes more than the base type, and always print in their own time zone.
- **LTZ** types (**DATETIMELTZ**, **TIMESTAMPLTZ**, also written *type* `WITH LOCAL TIME ZONE`) store the value in UTC only, and print it converted to the session time zone.

| Type | Input | Stored | Output |
|---|---|---|---|
| **DATE**, **TIME**, **DATETIME** | Without time zone | The value as entered | As entered |
| **DATETIMETZ** | With time zone | UTC + time zone | In the value's own time zone |
| **DATETIMELTZ** | With time zone | UTC | In the session time zone |
| **TIMESTAMP** | Without time zone | UTC (input read in the session time zone) | In the session time zone, without zone name |
| **TIMESTAMPTZ** | With time zone | UTC + time zone | In the value's own time zone |
| **TIMESTAMPLTZ** | With time zone | UTC | In the session time zone, with zone name |

Range, resolution and literal formats are the same as for the base types.

The session time zone is changed with `SET TIME ZONE`. The following stores the same wall-clock value, 2015-02-24 12:30, in each type while the session is at UTC+9, and reads it back at UTC+9, UTC+7 and in Europe/Bucharest (UTC+2 in February):

```sql
SET TIME ZONE '+09:00';
CREATE TABLE tz_demo (a DATETIME, b DATETIMETZ, c DATETIMELTZ, d TIMESTAMP, e TIMESTAMPTZ, f TIMESTAMPLTZ);
INSERT INTO tz_demo VALUES (DATETIME'2015-02-24 12:30', DATETIMETZ'2015-02-24 12:30', DATETIMELTZ'2015-02-24 12:30',
                            TIMESTAMP'2015-02-24 12:30', TIMESTAMPTZ'2015-02-24 12:30', TIMESTAMPLTZ'2015-02-24 12:30');
SELECT * FROM tz_demo;
SET TIME ZONE '+07:00';
SELECT * FROM tz_demo;
SET TIME ZONE 'Europe/Bucharest';
SELECT * FROM tz_demo;
```

| Session | DATETIME | DATETIMETZ | DATETIMELTZ | TIMESTAMP | TIMESTAMPTZ | TIMESTAMPLTZ |
|---|---|---|---|---|---|---|
| +09:00 | 2015-02-24 12:30:00.000 | 2015-02-24 12:30:00.000 +09:00 | 2015-02-24 12:30:00.000 +09:00 | 2015-02-24 12:30:00 | 2015-02-24 12:30:00 +09:00 | 2015-02-24 12:30:00 +09:00 |
| +07:00 | 2015-02-24 12:30:00.000 | 2015-02-24 12:30:00.000 +09:00 | 2015-02-24 10:30:00.000 +07:00 | 2015-02-24 10:30:00 | 2015-02-24 12:30:00 +09:00 | 2015-02-24 10:30:00 +07:00 |
| Europe/Bucharest | 2015-02-24 12:30:00.000 | 2015-02-24 12:30:00.000 +09:00 | 2015-02-24 05:30:00.000 Europe/Bucharest EET | 2015-02-24 05:30:00 | 2015-02-24 12:30:00 +09:00 | 2015-02-24 05:30:00 Europe/Bucharest EET |

**DATETIME** never changes, the **TZ** types keep the time zone they were stored with, and **TIMESTAMP** and the **LTZ** types follow the session.

> **Note:**
> **TIMESTAMP** is stored as seconds since 1970-01-01 00:00:00 UTC (the Unix epoch). If you come from a database whose **TIMESTAMP** keeps fractions of a second, the CoraDB equivalent is **DATETIME**.


**Converting between types with and without time zone**

| Conversion | Rule |
|---|---|
| String without time zone → **TIMESTAMP**, **TIMESTAMPLTZ**, **DATETIMELTZ** | Read in the session time zone, stored as UTC |
| String without time zone → **TIMESTAMPTZ**, **DATETIMETZ** | Read in the session time zone, stored as UTC with the session time zone |
| String without time zone → **DATETIME** | Stored as written |
| String with time zone → **TIMESTAMPLTZ**, **DATETIMELTZ** | Converted from its time zone to UTC |
| String with time zone → **TIMESTAMPTZ**, **DATETIMETZ** | Converted to UTC, its time zone is kept |
| String with time zone → **TIMESTAMP**, **DATETIME** | Error: the base types do not accept a time zone |
| **DATETIME** → **DATETIMETZ** | Read in the session time zone |
| **DATETIMETZ** → **DATETIME** | Keeps the date and time of the value's own time zone |
| **DATETIMELTZ**, **TIMESTAMPTZ**, **TIMESTAMPLTZ** → a type without time zone | The date and time in the session time zone |

In a session at Asia/Seoul (UTC+9 all year), for a value written as 2026-07-01 12:00 in Europe/Bucharest (UTC+3 in summer):

```sql
SET TIME ZONE 'Asia/Seoul';
SELECT CAST(DATETIMETZ'2026-07-01 12:00:00 Europe/Bucharest' AS DATETIME) AS tz_to_dt,
       CAST(DATETIMELTZ'2026-07-01 12:00:00 Europe/Bucharest' AS DATETIME) AS ltz_to_dt,
       CAST(DATETIME'2026-07-01 12:00:00' AS DATETIMETZ) AS dt_to_tz,
       CAST(TIMESTAMPTZ'2026-07-01 12:00:00 Europe/Bucharest' AS TIMESTAMP) AS tstz_to_ts;
```

| tz_to_dt | ltz_to_dt | dt_to_tz | tstz_to_ts |
|---|---|---|---|
| 2026-07-01 12:00:00.000 | 2026-07-01 18:00:00.000 | 2026-07-01 12:00:00.000 Asia/Seoul KST | 2026-07-01 18:00:00 |

When a value is printed, **TIMESTAMP** and **DATETIME** never show a time zone, the **LTZ** types show the session time zone, and the **TZ** types show their own.

### Time zone configuration

The following system parameters in `coradb.conf` control time zones. See [System parameters](https://www.coradb.ai/manual/admin/config.html#parameter-reference).

| Parameter | Meaning | Default |
|---|---|---|
| [timezone](https://www.coradb.ai/manual/admin/config_sql.html#timezone) | Time zone of a session | The value of **server_timezone** |
| [server_timezone](https://www.coradb.ai/manual/admin/config_sql.html#server_timezone) | Time zone of the server | The operating system's time zone |
| [tz_leap_second_support](https://www.coradb.ai/manual/admin/config_sql.html#tz_leap_second_support) | Leap second support | `no` |

A session changes its own time zone with `SET TIME ZONE 'Europe/Bucharest'` or `SET TIME ZONE '+02:00'`.

### Time zone functions

- [DBTIMEZONE](https://www.coradb.ai/manual/sql/function/information_fn.html#dbtimezone): the server time zone.
- [SESSIONTIMEZONE](https://www.coradb.ai/manual/sql/function/information_fn.html#sessiontimezone): the session time zone.
- [FROM_TZ](https://www.coradb.ai/manual/sql/function/datetime_fn.html#from_tz): adds a time zone to a **DATETIME** value.
- [NEW_TIME](https://www.coradb.ai/manual/sql/function/datetime_fn.html#new_time): converts a value from one time zone to another.
- [TZ_OFFSET](https://www.coradb.ai/manual/sql/function/datetime_fn.html#tz_offset): the UTC offset of a time zone.

### Functions and operators on time zone types

Every function and operator that accepts **DATETIME**, **TIMESTAMP** or **TIME** also accepts the corresponding time zone types, and the result keeps the time zone type. As with the base types, a number added to a **DATETIME** type counts milliseconds and a number added to a **TIMESTAMP** type counts seconds. In a session at Asia/Seoul:

```sql
SET TIME ZONE 'Asia/Seoul';
SELECT DATETIMELTZ'09/01/2009 03:30:30 PM' + 1 AS a,
       TIMESTAMPTZ'09/01/2009 03:30:30 PM' - 1 AS b;
```

| a | b |
|---|---|
| 2009-09-01 15:30:30.001 Asia/Seoul KST | 2009-09-01 15:30:29 Asia/Seoul KST |

An **LTZ** value is seen in the session time zone. 05:45 in Bucharest on 1986-10-15 (UTC+2 on that date) is 12:45 in Seoul, so [EXTRACT](https://www.coradb.ai/manual/sql/function/datetime_fn.html#extract) returns hour 5 for **DATETIMETZ** and hour 12 for **DATETIMELTZ**:

```sql
SET TIME ZONE 'Asia/Seoul';
SELECT EXTRACT(HOUR FROM DATETIMETZ'10/15/1986 5:45:15.135 AM Europe/Bucharest') AS tz_hour,
       EXTRACT(HOUR FROM DATETIMELTZ'10/15/1986 5:45:15.135 AM Europe/Bucharest') AS ltz_hour;
```

| tz_hour | ltz_hour |
|---|---|
| 5 | 12 |

### Conversion functions for time zone types

These functions convert between strings and date/time values, and understand time zone regions (`TZR`), daylight-saving abbreviations (`TZD`) and offsets (`TZH`, `TZM`):

- [DATE_FORMAT](https://www.coradb.ai/manual/sql/function/typecast_fn.html#date_format)
- [STR_TO_DATE](https://www.coradb.ai/manual/sql/function/typecast_fn.html#str_to_date)
- [TO_CHAR](https://www.coradb.ai/manual/sql/function/typecast_fn.html#fn-to_char)
- [TO_DATETIME_TZ](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_datetime_tz)
- [TO_TIMESTAMP_TZ](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_timestamp_tz)

```sql
SELECT DATE_FORMAT(DATETIMETZ'2012-02-02 10:10:10 Europe/Zurich CET', '%TZR %TZD %TZH %TZM') AS fmt,
       TO_DATETIME_TZ('2001-10-11 02:03:04 AM Europe/Bucharest EEST') AS dt,
       TO_TIMESTAMP_TZ('2001-10-11 02:03:04 AM Europe/Bucharest') AS ts;
```

| fmt | dt | ts |
|---|---|---|
| Europe/Zurich CET +01 00 | 2001-10-11 02:03:04.000 Europe/Bucharest EEST | 2001-10-11 02:03:04 Europe/Bucharest EEST |

[TO_DATETIME_TZ](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_datetime_tz) and [TO_TIMESTAMP_TZ](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_timestamp_tz) work like [TO_DATETIME](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_datetime) and [TO_TIMESTAMP](https://www.coradb.ai/manual/sql/function/typecast_fn.html#to_timestamp), except that the string can contain TZR, TZD, TZH and TZM information.

### IANA time zones

CoraDB uses the region names of the IANA (Internet Assigned Numbers Authority) time zone database, which records the history of local time, UTC offsets and daylight-saving rules for locations around the world. It is updated whenever governments change these rules; its maintenance is described in [BCP 175](https://tools.ietf.org/html/rfc6557). See <https://www.iana.org/time-zones>.

CoraDB ships with a compiled time zone library. To use a newer version of the database, update the time zone data, compile the library and restart the database; see [Compiling timezone library](https://www.coradb.ai/manual/sql/i18n_timezone.html#compiling-timezone-library).
