I'm trying to query a MongoDB collection to find an alarm between two dates. The problem is that the date is a timestamp. My code is:
rs.slaveOk(); print("mac;inicio;fin;valor_inicial;valor_actual"); db.alarmas.find( { timestamp_inicio_alarma: { $gt: ISODate("2018-02-01T00:00:00.000Z"), $lt: ISODate("2018-02-28T23:59:59.000Z") }, valor_inicial: {$eq: 'ON: AC Line Fail'}, estado_alarma: {$eq: 'SOLUCIONADA'} } ).forEach(function(alarmas){ print(alarmas.mac+";"+alarmas.timestamp_inicio_alarma+";"+alarmas.timestamp_fin_alarma+";"+alarmas.valor_inicial+";"+alarmas.valor_actual); } ); The data format is:
The problem is it's not finding anything. How can I query right?
Thank you very much. MongoDB it's a tool for me, I'm not a programmer.
