> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metrics-man.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quarter

# \$quarter

The `$quarter` operator extracts the quarter of the year from a date object (0-3).

## Input

* A single date object

## Output

* The quarter of the year as an integer (0-3, where 0 is Q1)

## Examples

### Extract Quarter from Date

```json theme={null}
{
  "$quarter": [
    {
      "$toDate": ["2023-05-15T10:30:00Z"]
    }
  ]
}
```

Result: `1` (Second quarter, 0-indexed as 1)

### Extract Quarter from Field

```json theme={null}
{
  "$quarter": [
    {
      "$input": "event_date"
    }
  ]
}
```

Result: The quarter (0-3) of the event\_date field
