Query to display all objects where timestamp greater than particular date

3,706 views
Skip to first unread message

sanmukho

unread,
Apr 26, 2011, 3:16:53 AM4/26/11
to mongodb-user
Hi

Will the below query work, if not then how to write "show me all
values where timestamp greater than particular date"

db.user.find( { timestamp :{$lt : Date() } } )

db.user.find( { timestamp :{$gt : Date() } } )

Thanks
Sandy

Chris Westin

unread,
Apr 26, 2011, 11:59:54 AM4/26/11
to mongodb-user
That example will query against "now," which probably isn't what you
want. But yes, you can do date range queries. See the How To article
here: http://cookbook.mongodb.org/patterns/date_range/ .

Chris

sanmukho

unread,
Apr 27, 2011, 8:30:35 AM4/27/11
to mongodb-user
Thanks Chris.
Reply all
Reply to author
Forward
0 new messages