Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get number of days between two dates mongodb query

db.collection.aggregate([
  {
    $project: {
      days: {
        $dateDiff: {
          startDate: "$start",
          endDate: "$end",
          unit: "day"
        }
      },
      _id: 0
    }
  }
])
Source by mongoplayground.net #
 
PREVIOUS NEXT
Tagged: #number #days #dates #mongodb #query
ADD COMMENT
Topic
Name
8+8 =