Skip to main content

$month

The $month operator extracts the month component from a date object (0-11).

Input

  • A single date object

Output

  • The month component of the date as an integer (0-11, where 0 is January)

Examples

Extract Month from Date

{
  "$month": [
    {
      "$toDate": ["2023-01-15T10:30:00Z"]
    }
  ]
}
Result: 0 (January, which is 0 in 0-11 range)

Extract Month from Field

{
  "$month": [
    {
      "$input": "event_date"
    }
  ]
}
Result: The month component (0-11) of the event_date field