E
E
Enter_a_nickname2021-08-03 13:50:54
MongoDB
Enter_a_nickname, 2021-08-03 13:50:54

How to count the number of records in mongoDB with a specific value?

Once a day, data is written to the database. Each record has the following field:
" Created: '2021-02-12 15:16:34' " It is
necessary to calculate how many records were received using Python code, for example, in the period from 2021-02-12 (from 18:00) to 2021- 02-13 (until 18:00)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Slava Rozhnev, 2021-08-03
@Enter_a_nickname

db.collection.find({
    created_at: {
        $gte: ISODate("2021-02-12 18:00:00.000Z"),
        $lt: ISODate("2021-02-13 18:00:00.000Z")
    }).count()

E
Egor Zhivagin, 2021-08-03
@Krasnodar_etc

count
Or get all the necessary records and calculate the length of the array using the language

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question