In my mongodb collection I have a record with:
//mongodb field: "birth_date": "1983-05-06T16:26:32.613Z"
And here my find query, to get that record in the range:
var birthYear = 1983;
var birthDateStart = new Date('1.1.' + birthYear); //Sat Jan 01 1983 00:00:00 GMT+0100 (Mitteleuropäische Zeit)
var birthDateEnd = new Date('12.30.' + birthYear); //Fri Dec 30 1983 00:00:00 GMT+0100 (Mitteleuropäische Zeit)
var cursor = db.collection('users').find({
birth_date: {$gte: birthDateStart, $lt: birthDateEnd}
})
I think the problem is the date format, how can I get the same Date() format as that in the database?
I used variety to get the DB schema:
+--------------------------------------------------+
| key | types | occurrences | percents |
| ------------ | -------- | ----------- | -------- |
| _id | ObjectId | 1 | 100.0 |
| bio | String | 1 | 100.0 |
| birth_date | String | 1 | 100.0 |
+--------------------------------------------------+
I use the 'mongodb' package for express.js - and can't use ISODate().
ReferenceError: ISODate is not defined