> ## 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

> 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(value)
```

### Formatted (scalar)

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

### Scaled (scalar)

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
to_timestamp(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.
* The numeric value can be a column. A constant NULL value or NULL scale can raise a format-related error.

## 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. |
| 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 UTC 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

* Numeric values are epoch seconds; DATE values become midnight.
* 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('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(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.


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