We are using Java and querying MongoDB. Want to get the records from a previous day. For example, we want to get all the students that enrolled yesterday. Here is the query that we use,
Date toDay = new Date();
Date twoDaysBack = Util.twoDaysBack(toDay);
query.put("enroldate", new BasicDBObject("$gt", twoDaysBack).append("$lt", toDay));
Say, if today is 22nd Nov, 2012. This query shows the list of students enrolled on 21st as well as 22nd even though we have specified $lt for today.
What is the issue here?