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

# DATETIME

> Sets a timestamp’s time zone without changing the instant it represents.

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

NULL timestamp yields NULL. NULL or invalid timezone raises an error.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
datetime(value [, timezone])
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | TIMESTAMP | Yes | Input timestamp. |
| timezone | STRING constant | No | Time zone for the result. Must be a constant argument. Default: UTC. |

## Returns

* Type: TIMESTAMP with the specified constant time zone; UTC by default
* NULL behavior: NULL timestamp yields NULL. NULL or invalid timezone raises an error.

## Properties

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

## Usage notes

* DATETIME takes a TIMESTAMP and an optional STRING time zone.
* Use the argument combinations in Syntax. Separate date/time components and numeric epoch overloads are outside these forms.

## Examples

### Basic example

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

| result |
| - |
| 2024-01-01 00:00:00 UTC |

### Keep a timestamp in UTC

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT datetime(TIMESTAMP '2024-02-29 12:30:00', 'UTC') AS leap_day;
```

| leap\_day |
| - |
| 2024-02-29 12:30:00 UTC |

## Limitations

* A constant time-zone argument sets the result’s time zone. For example, UTC produces a TIMESTAMP with microsecond precision and the UTC time zone.


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