There is a very simple solution to your challenge. Both Data formats (GMT and ISO FORMAT) can be passed easily.
Just follow the function below:
function findRows (){
//Convert the dates to strings
const isoDateInUTC1 = new Date("2015-05-12T01:40:08.963Z").getTime(),
isoDateInUTC2 = new Date("2015-05-12T01:40:08.963Z").getTime(),
rows= await collection.find({}).lean();
Let rowCount = 0;
for (let count = 0; count < trades.length; count++) {
var gmtDateUTC = new Date("").getTime(rows[count].Timestamp);
isoDateInUTC1 < gmtDateUTC < isoDateInUTC2
? rowCount++;
}
return rowCount;
}
I think this should work, although you should still be able to take the isoDateInUTC1
and isoDateInUTC2
as parameters so you can reuse the function. More so, You should be able to run a similar code in the mongodb query but this should still do the job.