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

# FROM_UNIXTIME_WITHUNIT

> Converts an epoch value in seconds or milliseconds to a UTC timestamp.

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

NULL value yields NULL. NULL/unknown unit raises an error; non-finite input or overflow raises an error.

## Syntax

### Scalar

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

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL | Yes | Epoch value. |
| unit | STRING constant | Yes | Second or millisecond unit. Must be a constant argument. |

## Returns

* Type: TIMESTAMP with UTC timezone
* NULL behavior: NULL value yields NULL. NULL/unknown unit raises an error; non-finite input or overflow raises an error.

## Properties

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

## Units

* Input unit: Epoch seconds or milliseconds UTC
* Output unit: Microsecond UTC timestamp
* Seconds \* 1000000; milliseconds \* 1000.

## Usage notes

* Second aliases: SECOND, SECONDS, SEC, SECS, S. Millisecond aliases: MILLISECOND, MILLISECONDS, MILLI, MILLIS, MS, MSEC.
* Unit matching trims whitespace and ignores case.
* Floats truncate converted microseconds toward zero; decimals round halfway away from zero.

## Examples

### Basic example

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT from_unixtime_withunit(1500,'MILLISECONDS') AS result;
```

| result |
| - |
| 1970-01-01 00:00:01.500000 UTC |

### Equivalent inputs in different units

Both inputs represent the same instant after the Unix epoch.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT from_unixtime_withunit(1, 'SECONDS') AS from_seconds, from_unixtime_withunit(1000, 'MILLISECONDS') AS from_milliseconds;
```

| from\_seconds | from\_milliseconds |
| - | - |
| 1970-01-01 00:00:01 UTC | 1970-01-01 00:00:01 UTC |

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