﻿---
title: Date and time functions
description: PromQL date and time functions in Elasticsearch that extract components from timestamps in UTC.
url: https://docs-v3-preview.elastic.dev/elastic/elasticsearch/pull/154987/reference/query-languages/promql/functions/date-time
products:
  - Elasticsearch
applies_to:
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Preview in 9.4
---

# Date and time functions
These functions extract date and time components from timestamps. All values are computed in UTC.

## `day_of_month`

<applies-to>Elastic Stack: Planned</applies-to>
Returns the day of the month for each of the input timestamps (in UTC). Returned values are from 1 to 31.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector, optional)">
    Optional instant vector input. If omitted, evaluation timestamp is used.
  </definition>
</definitions>

**Example**
```
day_of_month()
```


## `day_of_week`

<applies-to>Elastic Stack: Planned</applies-to>
Returns the day of the week for each of the input timestamps (in UTC). Returned values are from 0 to 6, where 0 means Sunday.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector, optional)">
    Optional instant vector input. If omitted, evaluation timestamp is used.
  </definition>
</definitions>

**Example**
```
day_of_week()
```


## `day_of_year`

<applies-to>Elastic Stack: Planned</applies-to>
Returns the day of the year for each of the input timestamps (in UTC). Returned values are from 1 to 366.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector, optional)">
    Optional instant vector input. If omitted, evaluation timestamp is used.
  </definition>
</definitions>

**Example**
```
day_of_year()
```


## `days_in_month`

<applies-to>Elastic Stack: Planned</applies-to>
Returns the number of days in the month for each of the input timestamps (in UTC). Returned values are from 28 to 31.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector, optional)">
    Optional instant vector input. If omitted, evaluation timestamp is used.
  </definition>
</definitions>

**Example**
```
days_in_month()
```


## `hour`

<applies-to>Elastic Stack: Planned</applies-to>
Returns the hour of the day for each of the input timestamps (in UTC). Returned values are from 0 to 23.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector, optional)">
    Optional instant vector input. If omitted, evaluation timestamp is used.
  </definition>
</definitions>

**Example**
```
hour()
```


## `minute`

<applies-to>Elastic Stack: Planned</applies-to>
Returns the minute of the hour for each of the input timestamps (in UTC). Returned values are from 0 to 59.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector, optional)">
    Optional instant vector input. If omitted, evaluation timestamp is used.
  </definition>
</definitions>

**Example**
```
minute()
```


## `month`

<applies-to>Elastic Stack: Planned</applies-to>
Returns the month of the year for each of the input timestamps (in UTC). Returned values are from 1 to 12.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector, optional)">
    Optional instant vector input. If omitted, evaluation timestamp is used.
  </definition>
</definitions>

**Example**
```
month()
```


## `time`

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Returns the number of seconds since January 1, 1970 UTC. Note that this does not actually return the current time, but the time at which the expression is being evaluated.
**Return type**
`scalar`
**Example**
```
time()
```


## `timestamp`

<applies-to>Elastic Stack: Planned</applies-to>
Returns the timestamp of each sample of the given vector as the number of seconds since January 1, 1970 UTC. It acts on float and histogram samples in the same way.
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector)">
    Instant vector input.
  </definition>
</definitions>

**Example**
```
timestamp(http_requests_total)
```


## `year`

<applies-to>Elastic Stack: Planned</applies-to>
Returns the year for each of the input timestamps (in UTC).
**Return type**
`instant_vector`
**Parameters**
<definitions>
  <definition term="v (instant_vector, optional)">
    Optional instant vector input. If omitted, evaluation timestamp is used.
  </definition>
</definitions>

**Example**
```
year()
```