# Chalk SQL Reference: Date and Time Functions
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions

See [date and time operators](https://docs.chalk.ai/docs/chalksql/expressions#date-and-time-operators) for infix arithmetic.

| Signature | Description |
| --- | --- |
| [`current_date()`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#current_date) | Returns the current date. |
| [`date(...)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#date) | Converts a `timestamp` or `string` to a date. |
| [`date_add(...)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#date_add) | Adds a `duration` or time-`unit` interval to a `date` or `timestamp`. |
| [`date_bin(bucket_width_seconds, origin_seconds, timestamp)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#date_bin) | Truncates a `timestamp` onto a fixed-width grid of ``bucket_width_seconds``, anchored at ``origin_seconds`` (seconds since the Unix epoch). |
| [`date_diff(unit, timestamp1, timestamp2)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#date_diff) | Returns the difference between two timestamps in the specified `unit`. |
| [`date_format(timestamp, format)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#date_format) | Formats a `timestamp` as a string using the specified `format`. |
| [`date_trunc(unit, x)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#date_trunc) | Truncates a timestamp to the specified time `unit` (e.g., day, month, year). |
| [`day(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#day) | Extracts the day of the month from a `date` or timestamp. |
| [`day_of_month(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#day_of_month) | Extracts the day of the month from a timestamp. |
| [`day_of_week(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#day_of_week) | Extracts the day of the week from a timestamp. |
| [`day_of_year(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#day_of_year) | Extracts the day of the month from a timestamp. |
| [`days_in_month(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#days_in_month) | Returns the number of days in the month of the given `date`. |
| [`dow(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#dow) | Extracts the day of the week from a `date` or timestamp. |
| [`doy(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#doy) | Extracts the day of the year from a `date` or timestamp. |
| [`format_datetime(timestamp, format)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#format_datetime) | Formats a datetime using a specified `format` string. |
| [`format_datetime_in_timezone(timestamp, format, timezone)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#format_datetime_in_timezone) | Formats a UTC `timestamp` as a string using a Joda `format` pattern in the given IANA `timezone`. |
| [`from_iso8601_date(string)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#from_iso8601_date) | Parses an ISO 8601 date `string` into a date value. |
| [`from_iso8601_timestamp(string)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#from_iso8601_timestamp) | Parses an ISO 8601 timestamp `string` into a datetime object. |
| [`from_unix_seconds(unixtime)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#from_unix_seconds) | Alias for [from_unixtime](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#from_unixtime). |
| [`from_unixtime(unixtime, ...)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#from_unixtime) | Converts a UNIX timestamp to a timestamp, optionally with a time zone offset. |
| [`hour(timestamp)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#hour) | Extracts the hour from a `timestamp`. |
| [`hour_in_timezone(timestamp, timezone)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#hour_in_timezone) | Extracts the hour from a `timestamp` on a given `timezone`. |
| [`is_business_day(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#is_business_day) | Returns true if the `date` falls on a weekday (Monday-Friday). |
| [`is_federal_holiday(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#is_federal_holiday) | Returns True if the given timestamp is a federal holiday. |
| [`last_day_of_month(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#last_day_of_month) | Returns the last day of the month for a given `date`. |
| [`make_date(year, month, day)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#make_date) | Constructs a date from `year`, `month`, and `day` fields. |
| [`millisecond(timestamp)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#millisecond) | Extracts the millisecond from a `timestamp`. |
| [`minute(timestamp)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#minute) | Extracts the minute from a `timestamp`. |
| [`month(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#month) | Extracts the month from a timestamp. |
| [`parse_datetime(string, format)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#parse_datetime) | Converts an ISO 8601 `string` into a datetime. |
| [`quarter(timestamp)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#quarter) | Extracts the quarter of the year from a `timestamp`. |
| [`second(timestamp)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#second) | Extracts the second from a `timestamp`. |
| [`to_days(days)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_days) | Constructs a duration with the given number of `days`. |
| [`to_hours(hours)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_hours) | Constructs a duration with the given number of `hours`. |
| [`to_iso8601(timestamp)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_iso8601) | Converts a datetime to an ISO 8601 string format. |
| [`to_microseconds(...)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_microseconds) | Converts a `duration` to `microseconds` or constructs a `duration` from `microseconds`. |
| [`to_milliseconds(...)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_milliseconds) | Converts a `duration` to `milliseconds` or constructs a `duration` from `milliseconds`. |
| [`to_minutes(minutes)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_minutes) | Constructs a duration with the given number of `minutes`. |
| [`to_months(months)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_months) | Constructs an interval with the given number of `months`. |
| [`to_seconds(seconds)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_seconds) | Constructs a duration with the given number of `seconds`. |
| [`to_unix_nanos(timestamp)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_unix_nanos) | Converts a `timestamp` or date to nanoseconds since the Unix epoch (UTC). Throws if the value falls outside the int64 ns range (~1677 to ~2262). |
| [`to_unixtime(timestamp)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_unixtime) | Converts a `timestamp` to Unix `timestamp` (seconds since epoch). |
| [`to_years(years)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_years) | Constructs an interval with the given number of `years`. |
| [`total_seconds(duration)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#total_seconds) | Returns the length of the input `duration` in seconds. |
| [`week(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#week) | Extracts the week of the year from a timestamp. |
| [`week_of_year(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#week_of_year) | Extracts the week of the year from a timestamp. |
| [`year(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#year) | Extracts the year from a timestamp. |
| [`year_of_week(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#year_of_week) | Extracts the year of the ISO week from a `date`. |
| [`yow(date)`](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#yow) | Extracts the year of the ISO week from a `date`. |

## `current_date()`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#current_date

Returns the current date.

**Parameters**

None

## `date(...)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#date

Converts a `timestamp` or `string` to a date.

**Examples**

```sql
SELECT date('2024-01-02');
```

```text
2024-01-02
```

**Overloads**

#### `date(timestamp)`

Converts a `timestamp` to a date.

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.

#### `date(string)`

Converts a `string` to a date.

**Parameters**

- `string`: `large_string`
  The input `string`.

## `date_add(...)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#date_add

Adds a `duration` or time-`unit` interval to a `date` or `timestamp`.

**Examples**

```sql
SELECT date_add('day', 7, TIMESTAMP '2024-01-02 00:00:00');
```

```text
2024-01-09 00:00:00
```

**Overloads**

#### `date_add(unit, value, timestamp)`

Adds the specified `value` of `unit` to a `timestamp`.

**Parameters**

- `unit`: `large_string`
  The time `unit`, such as 'second', 'day', or 'month'.
- `value`: `int64`
  The input `value`.
- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.

#### `date_add(date, duration)`

`date` + `duration` addition

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.
- `duration`: `duration[us]`
  The input `duration`.

#### `date_add(date, duration)`

`date` + month-day-nano interval addition

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.
- `duration`: `month_day_nano_interval`
  The input `duration`.

#### `date_add(date, duration)`

`date` + `duration` addition

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.
- `duration`: `duration[us]`
  The input `duration`.

#### `date_add(date, duration)`

`date` + month-day-nano interval addition

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.
- `duration`: `month_day_nano_interval`
  The input `duration`.

## `date_bin(bucket_width_seconds, origin_seconds, timestamp)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#date_bin

Truncates a `timestamp` onto a fixed-width grid of ``bucket_width_seconds``, anchored at ``origin_seconds`` (seconds since the Unix epoch).

**Parameters**

- `bucket_width_seconds`: `int64`
- `origin_seconds`: `int64`
- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.

## `date_diff(unit, timestamp1, timestamp2)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#date_diff

Returns the difference between two timestamps in the specified `unit`.

**Parameters**

- `unit`: `large_string`
  The time `unit`, such as 'second', 'day', or 'month'.
- `timestamp1`: `timestamp[us, tz=UTC]`
  The first timestamp.
- `timestamp2`: `timestamp[us, tz=UTC]`
  The second timestamp.

## `date_format(timestamp, format)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#date_format

Formats a `timestamp` as a string using the specified `format`.

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.
- `format`: `large_string`
  The `format` string.

## `date_trunc(unit, x)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#date_trunc

Truncates a timestamp to the specified time `unit` (e.g., day, month, year).

**Parameters**

- `unit`: `large_string`
  The time `unit`, such as 'second', 'day', or 'month'.
- `x`: `timestamp[us, tz=UTC]`
  The input value.

**Examples**

```sql
SELECT date_trunc('month', TIMESTAMP '2024-02-15 13:45:00') AS month_start;
```

```text
2024-02-01 00:00:00
```

## `day(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#day

Extracts the day of the month from a `date` or timestamp.

**Overloads**

#### `day(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `day(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `day(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `day_of_month(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#day_of_month

Extracts the day of the month from a timestamp.

**Overloads**

#### `day_of_month(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `day_of_month(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `day_of_month(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `day_of_week(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#day_of_week

Extracts the day of the week from a timestamp.

**Overloads**

#### `day_of_week(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `day_of_week(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `day_of_week(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `day_of_year(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#day_of_year

Extracts the day of the month from a timestamp.

**Overloads**

#### `day_of_year(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `day_of_year(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `day_of_year(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `days_in_month(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#days_in_month

Returns the number of days in the month of the given `date`.

**Examples**

```sql
SELECT days_in_month(DATE '2024-02-15') AS days;
```

```text
29
```

**Overloads**

#### `days_in_month(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `days_in_month(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `days_in_month(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `dow(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#dow

Extracts the day of the week from a `date` or timestamp.

**Overloads**

#### `dow(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `dow(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `dow(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `doy(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#doy

Extracts the day of the year from a `date` or timestamp.

**Overloads**

#### `doy(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `doy(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `doy(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `format_datetime(timestamp, format)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#format_datetime

Formats a datetime using a specified `format` string.

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.
- `format`: `large_string`
  The `format` string.

## `format_datetime_in_timezone(timestamp, format, timezone)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#format_datetime_in_timezone

Formats a UTC `timestamp` as a string using a Joda `format` pattern in the given IANA `timezone`.

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.
- `format`: `large_string`
  The `format` string.
- `timezone`: `large_string`
  The IANA `timezone` name, such as 'America/New_York'.

## `from_iso8601_date(string)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#from_iso8601_date

Parses an ISO 8601 date `string` into a date value.

**Parameters**

- `string`: `large_string`
  The input `string`.

## `from_iso8601_timestamp(string)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#from_iso8601_timestamp

Parses an ISO 8601 timestamp `string` into a datetime object.

**Parameters**

- `string`: `large_string`
  The input `string`.

## `from_unix_seconds(unixtime)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#from_unix_seconds

Alias for [from_unixtime](https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#from_unixtime).

## `from_unixtime(unixtime, ...)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#from_unixtime

Converts a UNIX timestamp to a timestamp, optionally with a time zone offset.

**Examples**

```sql
SELECT from_unixtime(1700000000);
```

```text
2023-11-14 22:13:20 UTC
```

**Overloads**

#### `from_unixtime(unixtime, hours, minutes)`

Returns the UNIX timestamp `unixtime` as a timestamp with time zone using `hours` and `minutes` for the time zone offset.

**Parameters**

- `unixtime`: `double`
- `hours`: `int64`
  The number of `hours`.
- `minutes`: `int64`
  The number of `minutes`.

#### `from_unixtime(unixtime)`

Returns the UNIX timestamp `unixtime` as a timestamp with time zone.

**Parameters**

- `unixtime`: `double`

## `hour(timestamp)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#hour

Extracts the hour from a `timestamp`.

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.

## `hour_in_timezone(timestamp, timezone)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#hour_in_timezone

Extracts the hour from a `timestamp` on a given `timezone`.

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.
- `timezone`: `large_string`
  The IANA `timezone` name, such as 'America/New_York'.

## `is_business_day(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#is_business_day

Returns true if the `date` falls on a weekday (Monday-Friday).

**Overloads**

#### `is_business_day(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `is_business_day(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `is_business_day(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `is_federal_holiday(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#is_federal_holiday

Returns True if the given timestamp is a federal holiday.

**Overloads**

#### `is_federal_holiday(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `is_federal_holiday(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `is_federal_holiday(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `last_day_of_month(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#last_day_of_month

Returns the last day of the month for a given `date`.

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `make_date(year, month, day)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#make_date

Constructs a date from `year`, `month`, and `day` fields.

**Parameters**

- `year`: `int64`
- `month`: `int64`
- `day`: `int64`

## `millisecond(timestamp)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#millisecond

Extracts the millisecond from a `timestamp`.

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.

## `minute(timestamp)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#minute

Extracts the minute from a `timestamp`.

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.

## `month(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#month

Extracts the month from a timestamp.

**Overloads**

#### `month(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `month(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `month(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `parse_datetime(string, format)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#parse_datetime

Converts an ISO 8601 `string` into a datetime.

**Parameters**

- `string`: `large_string`
  The input `string`.
- `format`: `large_string`
  The `format` string.

## `quarter(timestamp)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#quarter

Extracts the quarter of the year from a `timestamp`.

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.

## `second(timestamp)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#second

Extracts the second from a `timestamp`.

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.

## `to_days(days)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_days

Constructs a duration with the given number of `days`.

**Overloads**

#### `to_days(days)`

**Parameters**

- `days`: `int64`
  The number of `days`.

#### `to_days(days)`

**Parameters**

- `days`: `double`
  The number of `days`.

## `to_hours(hours)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_hours

Constructs a duration with the given number of `hours`.

**Overloads**

#### `to_hours(hours)`

**Parameters**

- `hours`: `int64`
  The number of `hours`.

#### `to_hours(hours)`

**Parameters**

- `hours`: `double`
  The number of `hours`.

## `to_iso8601(timestamp)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_iso8601

Converts a datetime to an ISO 8601 string format.

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.

**Examples**

```sql
SELECT to_iso8601(TIMESTAMP '2024-01-02 03:04:05');
```

```text
2024-01-02T03:04:05.000000Z
```

## `to_microseconds(...)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_microseconds

Converts a `duration` to `microseconds` or constructs a `duration` from `microseconds`.

**Overloads**

#### `to_microseconds(duration)`

Converts a `duration` to microseconds.

**Parameters**

- `duration`: `duration[us]`
  The input `duration`.

#### `to_microseconds(duration)`

Converts a `duration` to microseconds.

**Parameters**

- `duration`: `duration[us]`
  The input `duration`.

#### `to_microseconds(microseconds)`

Constructs a duration with the given number of `microseconds`.

**Parameters**

- `microseconds`: `int64`
  The number of `microseconds`.

#### `to_microseconds(duration)`

Converts a `duration` to microseconds.

**Parameters**

- `duration`: `duration[us]`
  The input `duration`.

#### `to_microseconds(microseconds)`

Constructs a duration with the given number of `microseconds`.

**Parameters**

- `microseconds`: `double`
  The number of `microseconds`.

## `to_milliseconds(...)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_milliseconds

Converts a `duration` to `milliseconds` or constructs a `duration` from `milliseconds`.

**Overloads**

#### `to_milliseconds(duration)`

Converts a `duration` to milliseconds.

**Parameters**

- `duration`: `duration[us]`
  The input `duration`.

#### `to_milliseconds(duration)`

Converts a `duration` to milliseconds.

**Parameters**

- `duration`: `duration[us]`
  The input `duration`.

#### `to_milliseconds(milliseconds)`

Constructs a duration with the given number of `milliseconds`.

**Parameters**

- `milliseconds`: `int64`
  The number of `milliseconds`.

#### `to_milliseconds(duration)`

Converts a `duration` to milliseconds.

**Parameters**

- `duration`: `duration[us]`
  The input `duration`.

#### `to_milliseconds(milliseconds)`

Constructs a duration with the given number of `milliseconds`.

**Parameters**

- `milliseconds`: `double`
  The number of `milliseconds`.

## `to_minutes(minutes)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_minutes

Constructs a duration with the given number of `minutes`.

**Overloads**

#### `to_minutes(minutes)`

**Parameters**

- `minutes`: `int64`
  The number of `minutes`.

#### `to_minutes(minutes)`

**Parameters**

- `minutes`: `double`
  The number of `minutes`.

## `to_months(months)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_months

Constructs an interval with the given number of `months`.

**Overloads**

#### `to_months(months)`

**Parameters**

- `months`: `int64`

#### `to_months(months)`

**Parameters**

- `months`: `double`

## `to_seconds(seconds)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_seconds

Constructs a duration with the given number of `seconds`.

**Overloads**

#### `to_seconds(seconds)`

**Parameters**

- `seconds`: `int64`
  The number of `seconds`.

#### `to_seconds(seconds)`

**Parameters**

- `seconds`: `double`
  The number of `seconds`.

## `to_unix_nanos(timestamp)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_unix_nanos

Converts a `timestamp` or date to nanoseconds since the Unix epoch (UTC). Throws if the value falls outside the int64 ns range (~1677 to ~2262).

**Overloads**

#### `to_unix_nanos(timestamp)`

**Parameters**

- `timestamp`: `date32[day]`
  The input `timestamp`.

#### `to_unix_nanos(timestamp)`

**Parameters**

- `timestamp`: `date64[ms]`
  The input `timestamp`.

#### `to_unix_nanos(timestamp)`

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.

## `to_unixtime(timestamp)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_unixtime

Converts a `timestamp` to Unix `timestamp` (seconds since epoch).

**Parameters**

- `timestamp`: `timestamp[us, tz=UTC]`
  The input `timestamp`.

## `to_years(years)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#to_years

Constructs an interval with the given number of `years`.

**Overloads**

#### `to_years(years)`

**Parameters**

- `years`: `int64`

#### `to_years(years)`

**Parameters**

- `years`: `double`

## `total_seconds(duration)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#total_seconds

Returns the length of the input `duration` in seconds.

**Parameters**

- `duration`: `duration[us]`
  The input `duration`.

## `week(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#week

Extracts the week of the year from a timestamp.

**Overloads**

#### `week(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `week(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `week(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `week_of_year(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#week_of_year

Extracts the week of the year from a timestamp.

**Overloads**

#### `week_of_year(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `week_of_year(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `week_of_year(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `year(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#year

Extracts the year from a timestamp.

**Overloads**

#### `year(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `year(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `year(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `year_of_week(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#year_of_week

Extracts the year of the ISO week from a `date`.

**Overloads**

#### `year_of_week(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `year_of_week(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `year_of_week(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.

## `yow(date)`
source: https://docs.chalk.ai/docs/chalksql/functions/date-and-time-functions#yow

Extracts the year of the ISO week from a `date`.

**Overloads**

#### `yow(date)`

**Parameters**

- `date`: `date32[day]`
  The input `date` or timestamp.

#### `yow(date)`

**Parameters**

- `date`: `date64[ms]`
  The input `date` or timestamp.

#### `yow(date)`

**Parameters**

- `date`: `timestamp[us, tz=UTC]`
  The input `date` or timestamp.
