MongoDB Date Operators

MongoDB date operators are a set of special operators used for handling date type fields. They can be used for formatting, converting, and comparing dates in both aggregation and regular queries. This page summarizes the date operators available in MongoDB.

  1. $dateFromParts

    $dateFromParts is a date operator in MongoDB that can be used to combine the given date components (such as year, month, day, etc.) into a date object.
  2. $dateFromString

    $dateFromString is a MongoDB aggregation operator used to convert a string into a date object.
  3. $dateToParts

    The MongoDB $dateToParts operator can convert dates to corresponding parts such as year, month, day, etc., to enable more flexible data processing and aggregation operations.
  4. $dateToString

    The MongoDB $dateToString operator is used to convert a date field to a string and format the date into a specified string format.
  5. $dayOfMonth

    The MongoDB $dayOfMonth operator is an aggregation expression used to extract the day of the month (1-31) from a date field.
  6. $dayOfWeek

    $dayOfWeek is an aggregation operator in MongoDB used to extract the day of the week information from a date value.
  7. $dayOfYear

    The $dayOfYear operator is one of the date operators in MongoDB’s aggregation pipeline.
  8. $hour

    The MongoDB $hour operator is an aggregation operator used to extract the hour portion from a datetime value.
  9. $isoDayOfWeek

    The MongoDB $isoDayOfWeek operator is an aggregation operator used to extract the day of the week in ISO standard from a date-time value.
  10. $isoWeek

    The MongoDB $isoWeek operator can be used to process and filter date data.
  11. $isoWeekYear

    In MongoDB, $isoWeekYear is an aggregation operator used to retrieve the year of an ISO week date.
  12. $millisecond

    In MongoDB, the $millisecond operator is used to extract the millisecond portion from a date.
  13. $minute

    The $minute operator is a date operator in MongoDB used to extract the minute portion from a date.
  14. $month

    $month operator is a date operator in MongoDB aggregation pipeline, which extracts the month from a date field and can be used in aggregation operations.
  15. $second

    $second is one of the date operators in MongoDB used to handle datetime types.
  16. $week

    In MongoDB, the $week operator can be used to extract the week number from a date field.
  17. $year

    The $year operator is one of the operators used to manipulate date-time types and extract the year from a date-time field.
  18. Date()

    In MongoDB, the Date() method can be used to create a JavaScript Date object that represents a date and time.