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

# Weekofyear

# \$weekOfYear

The `$weekOfYear` operator extracts the week of the year from a date object (0-53).

## Input

* A single date object

## Output

* The week of the year as an integer (0-53, where 0 is the first week)

## Examples

### Extract Week of Year from Date

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

Result: `1` (Week number 2, 0-indexed as 1)

### Extract Week of Year from Field

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

Result: The week of the year (0-53) of the event\_date field
