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

> Returns epoch seconds from a timestamp or explicitly formatted string.

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

**Aliases:** [`unix_timestamp`](/query/sql/functions/date-time/unix_timestamp), [`to_unixtime`](/query/sql/functions/date-time/to_unixtime)

NULL timestamp, value or format yields NULL. Invalid string/timezone conversion raises an error.

## Syntax

### Timestamp (scalar)

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

### Parsed (scalar)

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

### Unix timestamp timestamp (scalar)

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

### Unix timestamp parsed (scalar)

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

### To unixtime timestamp (scalar)

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

* TO\_UNIXTIME accepts exactly one TIMESTAMP operand. No no-argument/string parsing form.

## Arguments

### Timestamp, unix timestamp timestamp, to unixtime timestamp

| Name | Type | Required | Description |
| - | - | - | - |
| value | TIMESTAMP | Yes | Instant to convert to epoch seconds. |

### Parsed, unix timestamp parsed

| Name | Type | Required | Description |
| - | - | - | - |
| value | STRING | Yes | String to parse. |
| format | STRING | Yes | Parsing pattern. |

## Returns

* Type: BIGINT
* NULL behavior: NULL timestamp, value or format yields NULL. Invalid string/timezone conversion raises an error.

### To unixtime timestamp

* Type: BIGINT
* NULL behavior: NULL timestamp, value or format yields NULL. Invalid string/timezone conversion raises an error.

## Properties

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

## Units

* Input unit: Timestamp or formatted text
* Output unit: Signed seconds since Unix epoch UTC
* Microseconds / 1000000, truncating toward zero.

## Usage notes

* Fractional seconds are truncated toward zero, including negative epoch values.
* Pass a TIMESTAMP, or pass a STRING together with its format. An unformatted STRING is not part of these calling forms.

## Examples

### Basic example

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT to_unix_timestamp(TIMESTAMP '2024-01-01 00:00:00') AS result;
```

| result |
| - |
| 1704067200 |

### Alias calling form: UNIX\_TIMESTAMP

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT unix_timestamp(TIMESTAMP '2024-01-01 00:00:00') AS result;
```

| result |
| - |
| 1704067200 |

### Alias calling form: TO\_UNIXTIME

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT to_unixtime(TIMESTAMP '2024-01-01 00:00:00') AS result;
```

| result |
| - |
| 1704067200 |

## Limitations

* TO\_UNIXTIME accepts a TIMESTAMP. The STRING-with-format, DATE, unformatted STRING, and no-argument forms are not available through this alias.

## Related functions

* [from\_unixtime](/query/sql/functions/date-time/from_unixtime)


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