How to send data on a given date

I use mongoexport to export data for given dates. My team is

mongoexport -d project -c coll  --csv -o result -f source -q '{"date":{"$gte":"new Date(2011,1,25)","lt":"new Date(2011,2,26)"}}'

but it doesn’t export the result ... I have data stored in the database 25-feb-2011 and 26-feb-2011 in the database. How can I request dates?

+5
source share
4 answers

I had the same problem. I fixed it using era time.

Here you can check out http://www.epochconverter.com/

I used java .. so I used

Date x = new Date (year, month, day)

and got the era using x.getTime () and sent it to mongoexport

so ur mongo export expression will be

mongoexport -d project -c coll --csv -o result -f source -q '{ "date": {$ gte: ( (1295913600)), $lt: ( (1298678400)}}'

+5

, , .

-, , new Date(....) ( , ?).

-, , Date(Y,M,D) - :

: 10340: JSON ...

, .
,
new Date(1234567890)

, :

mongoexport -d project -c coll  --csv -o result -f source -q '{"date":{"$gte":new Date(x)","$lt":new Date(y)}}'

x = y = . , "$" "lt", .

Update:
Re: . . , mongo, (, 25-feb:

> new Date(2009,1,25) * 1

:

1235520000000

, :

> new Date(1235520000000)

, :

ISODate("2009-02-25T00:00:00Z")
+2

, Wael mokoexport 2.2.4, :

$and:[{date:{$gte:new Date(1372801816000)}},{date:{$lt:new Date(1373061846000)}}]}

. mongo ( --jsonArray --csv)

mongoexport -h your_host:port -d your_db -c your_collection --jsonArray -o output.js -q '{$and:[{date:{$gte:new Date(time_stamp_1)}},{date:{$lt:new Date(time_stamp_2)}}]}'
+2

I just stumbled upon this, and it seems that the problem in the original message is that new Date(2011,2,26)it should not have been wrapped in quotation marks, but "lt"should have been "$lt". Also, new Date(2011,2,26)March 26th, 2011, because javascript uses a range of 0-11 for month values.

+1
source

All Articles