$lt (Less Than)
Last updated: 2026-10-09
$lt (Less Than)
$lt selects documents where a field value is strictly less than the specified value. `{ price: { $lt: 20 } }` matches products priced under 20. It handles price caps, cutoff dates and score ceilings, and combines with $gt for an open interval. Strings compare lexicographically, dates chronologically; $lt is type-sensitive.
| Category | Comparison |
|---|---|
| MongoDB Version | 1.0+ |
| Example Language | mongosh (Shell) |
📝 Syntax
{ <field>: { $lt: <value> } }
⚙️ Parameters
| field | The document field to match. |
|---|---|
| value | The upper-bound value; the boundary itself is excluded. |
Returns:Cursor of matching documents
▶ Example
Run the commands below in your local mongosh (requires a running mongod):
// $lt: products priced under 20
db.products.find({ price: { $lt: 20 } })
// Users registered before the cutoff date
db.users.find({ registeredAt: { $lt: new Date('2026-01-01') } })
Output:
// Returns products under 20 and users registered before Jan 1, 2026
📌 Notes
- $lt excludes the boundary; use $lte to include it
- Combine $gt and $lt on one field for an open interval, e.g. { score: { $gt: 60, $lt: 90 } }
- Passing a date string directly compares lexicographically; always use new Date()
🏷️ Related Tags
💡 Related Cases
📚 Related Tutorials
❓ FAQ
QWhat is the difference between $lt and $lte?
A$lt is strictly less (excludes the boundary); $lte includes it. Use $lt: 20 for below 20 and $lte: 20 for at most 20.
QHow do I query scores between 60 and 90?
ACombine on one field: { score: { $gt: 60, $lt: 90 } } — an open interval.
QWhat should I watch for when using $lt on dates?
AWrap dates in new Date('YYYY-MM-DD'); raw strings compare lexicographically and can surprise you.