[SERVER-3259] Using a date timestamp with mongo --eval yields zero results Created: 14/Jun/11  Updated: 29/Aug/11  Resolved: 15/Jun/11

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 1.8.1
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Ryan Felton Assignee: Scott Hernandez (Inactive)
Resolution: Done Votes: 2
Labels: query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac OSX 10.6.7 64 bit


Operating System: ALL
Participants:

 Description   

When running the query in the mongo shell, the query returns the proper result:

mongo localhost:27017/development
> db.statistics.find({'type': 'Hourly', 'statistics_date' : {'$lt': new Date(1307145600000)}}).count();
21316

However, when performing the query via eval, the query always returns 0 results.

mongo localhost:27017/development --eval "db.statistics.find({'type': 'Hourly', 'statistics_date' : {'$lt': new Date(1307145600000)}}).count();"
MongoDB shell version: 1.8.1
connecting to: localhost:27017/development
0



 Comments   
Comment by Scott Hernandez (Inactive) [ 15/Jun/11 ]

closed

Comment by Ryan Felton [ 15/Jun/11 ]

Yep, that worked.. Thanks!

How do I close this ticket?

Comment by Scott Hernandez (Inactive) [ 14/Jun/11 ]

The problem is the variable substitution from the shell (bash/sh) "$" which is being replaced.

Try "db.statistics.find({'type': 'Hourly', 'statistics_date' : {'\$lt': new Date(1307145600000)}}).count();"

Generated at Thu Feb 08 03:02:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.