Skip to main content

$hour

The $hour operator extracts the hour component from a date object (0-23).

Input

  • A single date object

Output

  • The hour component of the date as an integer (0-23)

Examples

Extract Hour from Date

{
  "$hour": [
    {
      "$toDate": ["2023-01-15T10:30:00Z"]
    }
  ]
}
Result: 10

Extract Hour from Field

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