I would like to know how I can make a query of this type in MongoDB with date difference and taking the last record in a date range.
SELECT *, DATEDIFF(NOW(),DATAHORA) AS DIAS FROM TBLTRANSFERS
WHERE IDTRANSFER IN (SELECT MAX(IDTRANSFER)
FROM TBLTRANSFERS WHERE DATAHORA BETWEEN '2017-10-26 11:42:28'
AND '2017-11-13 11:42:28'
AND (EVENTO = 1 OR EVENTO = 3)
AND RESULTADO = 0 GROUP BY USUARIO)
ORDER BY USUARIO DESC;