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?
What is the issue here?The issue is that you didn't include what is the error message, or the problem you receive when running the code...