# ToDateTime

Converts from milliseconds to a formatted date-time string, based on the provided [Joda-Time pattern](https://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html).

## Signature

> ToDate(millis, pattern)&#x20;
>
> ToDate(millis, pattern, timezoneId)

## Usage Examples

```sql
SELECT ToDateTime(1639137263000, 'yyyy-MM-dd') AS dateTimeString
FROM ignoreMe
```

| dateTimeString |
| -------------- |
| 2021-12-10     |

```sql
SELECT ToDateTime(
    1639137263000, 
    'yyyy-MM-dd hh:mm:ss a'
    ) AS dateTimeString
FROM ignoreMe
```

| dateTimeString         |
| ---------------------- |
| 2021-12-10 11:54:23 AM |

```sql
SELECT ToDateTime(
    1639137263000, 
    'yyyy-MM-dd HH:mm:ss Z',
    'CET'
    ) AS dateTimeString
FROM ignoreMe
```

| dateTimeString            |
| ------------------------- |
| 2021-12-10 12:54:23 +0100 |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pinot.apache.org/release-0.10.0/configuration-reference/functions/todatetime.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
