var start = new Date(2010, 3, 1);
var end = new Date(2010, 4, 1);
db.posts.find({created_on: {$gte: start, $lt: end}});
but i don't want to use two dates.
i need to use single date for search
please send response as soon as possible
it is too urgent.
like select * from emp table where date="12/14/2011" like that(in sql)
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
var date = ISODate("2010-04-01")
Calendar currentDate= Calendar.getInstance();Date dateNow = currentDate.getTime();JSONObject jsobj= new JSONObject();jsobj.put("todaydate", todaydate);mongoDb.append(query,jsobj );data inside Db is{"phonehome" : "12412442","adddate" : new Date("Mon, 12 Dec 2011 12:35:00 GMT +05:30")}i tried this querydb.users.find({ "adddate" : "new Date(2011,12,12)" });
but this is not working.
1. The date value stored in your database has a time component so it
can't match a date where the time component is zero
2. "new Date(2011, 12, 12)" is a string, not a Date, because you put
quotes around it
Also, 12 is not a valid month for the Javascript Date constructor
(which uses 0 - 11).
Not sure what the bit about the document with the doctor field was about.
> db.users.remove()
> db.users.insert({_id:1, adddate:new Date(2011,10,11)})
> db.users.find({ "adddate" : new Date(2011,10,11) });
{ "_id" : 1, "adddate" : ISODate("2011-11-11T05:00:00Z") }
>
I'm not very familiar with MongoVUE, but I would imagine it takes the
same queries as the mongo shell.
On Sat, Dec 17, 2011 at 1:26 AM, nagamuni reddy
My first guess is that your Dates are not equal. Might be something as
simple as timezone issues.
I recommend you use the mongo shell ISODate helper function instead of
the Date constructor.
Here's a working example in Javascript in the mongo shell:
> db.test.remove()
> db.test.insert({_id:1,adddate:ISODate("2011-12-01")})
> db.test.insert({_id:2,adddate:ISODate("2011-12-02")})
> db.test.find()
{ "_id" : 1, "adddate" : ISODate("2011-12-01T00:00:00Z") }
{ "_id" : 2, "adddate" : ISODate("2011-12-02T00:00:00Z") }
> db.test.find({adddate:ISODate("2011-12-01")})
{ "_id" : 1, "adddate" : ISODate("2011-12-01T00:00:00Z") }
>
On Mon, Dec 19, 2011 at 1:05 PM, nagamuni reddy