MongoDB $floor Operator (original) (raw)

Last Updated : 11 Feb, 2026

The $floor operator in MongoDB rounds a number down to the nearest integer within aggregation pipelines, making numeric values suitable for reporting and analysis.

Syntax

{ $floor: }

Use Cases of the $floor Operator

Here are some use cases:

Examples of MongoDB $floor

In the following examples, we are working with:

Screenshot-2026-02-11-122344

Example 1: Using $floor operator

Find the largest integer less than or equal to the value of the perfoPoint field in the development department.

db.employee.aggregate([
{ $match: { department: "Development" } },
{
$project: {
perfoPoint: 1,
floorPoint: { floor:"floor: "floor:"perfoPoint" }
}
}
])

**Output:

floor

Example 2: Using $floor operator in the embedded document

Find the largest integer less than or equal to the value of the details.perfoPoint field in the HR department. Here, the field is inside an embedded document.

db.employee.aggregate([
{ $match: { department: "HR" } },
{
$project: {
"details.perfoPoint": 1,
floorPoint: { floor:"floor: "floor:"details.perfoPoint" }
}
}
])

**Output:

floor2