Skip to main content

$dayOfWeek

The $dayOfWeek operator extracts the day of the week from a date object (0-6, where 0 is Sunday).

Input

  • A single date object

Output

  • The day of the week as an integer (0-6, where 0 is Sunday)

Examples

Extract Day of Week from Date

{
  "$dayOfWeek": [
    {
      "$toDate": ["2023-01-15T10:30:00Z"]
    }
  ]
}
Result: 0 (Sunday)

Extract Day of Week from Field

{
  "$dayOfWeek": [
    {
      "$input": "event_date"
    }
  ]
}
Result: The day of the week (0-6) of the event_date field