Skip to main content

$addDays

The $addDays operator adds a specified number of days to a date object.

Input

  • An array containing a date object and an integer number of days to add

Output

  • A new date object with the specified number of days added

Examples

Add Days to Date

{
  "$addDays": [
    {
      "$toDate": ["2023-01-15T10:30:00Z"]
    },
    10
  ]
}
Result: Date object representing January 25, 2023 at 10:30:00 UTC

Add Days to Field Value

{
  "$addDays": [
    {
      "$input": "start_date"
    },
    {
      "$input": "days_to_add"
    }
  ]
}
Result: A new date with days_to_add added to the start_date field