Skip to content

Instantly share code, notes, and snippets.

@caprica
Created October 6, 2021 18:18
Show Gist options
  • Save caprica/57e73e4b88aaf6b9307dfbbb39083490 to your computer and use it in GitHub Desktop.
Save caprica/57e73e4b88aaf6b9307dfbbb39083490 to your computer and use it in GitHub Desktop.
MongoDB query between two dates
db.collectionName.find(
{
$and: [
{"timestamp": {$gte: ISODate('2021-10-05T00:00:00.000Z')}},
{"timestamp": {$lt: ISODate('2021-10-06T00:00:00.000Z')}}
]
}
)
db.collectionName.count(
{
$and: [
{"timestamp": {$gte: ISODate('2021-10-05T00:00:00.000Z')}},
{"timestamp": {$lt: ISODate('2021-10-06T00:00:00.000Z')}}
]
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment