> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TO_TIMESTAMP_TZ

> Converts a value to a timezone-bearing timestamp.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

NULL value yields NULL. For malformed non-NULL strings ANSI mode raises an error; non-ANSI mode yields NULL. Numeric overflow/non-finite conversions can raise errors.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
to_timestamp_tz(value)
```

### Formatted (scalar)

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
to_timestamp_tz(text,format)
```

### Scaled (scalar)

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
to_timestamp_tz(numeric_value,scale)
```

* Use integer epoch values and a constant BIGINT scale; floating-point and decimal operands can select string-format handling instead of epoch scaling.
* Integer division by 10^scale discards the subsecond remainder.
* Both arguments must be constants. Numeric columns can raise an argument error, including with TRY variants.

## Arguments

### Scalar

| Name | Type | Required | Description |
| - | - | - | - |
| value | STRING, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL(p, s), DATE or TIMESTAMP | Yes | Value to convert; numeric input is epoch seconds. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). |

### Formatted

| Name | Type | Required | Description |
| - | - | - | - |
| text | STRING | Yes | Text to parse. |
| format | STRING | Yes | Parsing pattern; per-row patterns are accepted. |

### Scaled

| Name | Type | Required | Description |
| - | - | - | - |
| numeric\_value | TINYINT, SMALLINT, INTEGER or BIGINT | Yes | Scaled integer epoch value. Epoch units before division by 10^scale. Explicitly CAST floating-point and decimal values to BIGINT before this call. Must be a constant argument. |
| scale | BIGINT | Yes | Base-10 epoch scale. A non-NULL constant from 0 through 18; use an explicit CAST to BIGINT. Must be a constant argument. |

## Returns

* Type: TIMESTAMP with timezone
* NULL behavior: NULL value yields NULL. For malformed non-NULL strings ANSI mode raises an error; non-ANSI mode yields NULL. Numeric overflow/non-finite conversions can raise errors.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Exact result | Yes |

## Usage notes

* Parsed text keeps its time zone. If no time zone is present, UTC is used.
* When parsing several values together, the first parsed time zone can be applied to all results. Avoid mixing time zones in one input column.
* NULL explicit format raises an error.
* In the two-number form, scale must be an integer from 0 through 18. The value is divided by 10^scale to obtain whole seconds; any fractional second is discarded.
* Invalid-input behavior depends on the query’s ANSI mode. See the NULL and error rules above.
* INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

## Examples

### Basic example

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT to_timestamp_tz('2024-03-15 10:30:00') AS result;
```

| result |
| - |
| 2024-03-15 10:30:00 UTC |

### Convert a date to midnight

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT to_timestamp_tz(DATE '2024-02-29') AS midnight;
```

| midnight |
| - |
| 2024-02-29 00:00:00 UTC |

## Limitations

* Use the format arguments shown here. Formats that vary by row are outside the forms covered on this page.
* The scaled form requires the constant integer arguments described above. Cast FLOAT, DOUBLE, or DECIMAL values to BIGINT explicitly before using them as epoch units.

## Related functions

* [to\_timestamp](/query/sql/functions/date-time/to_timestamp)
* [to\_timestamp\_ntz](/query/sql/functions/date-time/to_timestamp_ntz)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.