This is the log from mongo with
whereobj.tm=new Date(1314547200000)
tm: { $gt: "2011-08-28T13:00:00.000Z", $lt:
"2011-08-28T16:00:00.000Z" }
new Date(1314547200000) in javascript will give a date object.
coffee> new Date(1314536400000)
Sun, 28 Aug 2011 13:00:00 GMT
new Date() in mongo shell work because mongo shell wrap it into
isodate() type. However, in node.js, it is not.
Date time should be the basic and it not working....not sure what's
wrong.
On Nov 7, 11:27 pm, Antoine Girbal <
anto...@10gen.com> wrote:
> using "new Date(1314536400000)" should work both in shell and node.js.
> are you sure that you connect to the right db/collection? (maybe you
> can test by printing the result of collection.count())
>
> On Nov 7, 8:02 am, life0fun <
life0...@gmail.com> wrote:
>
>
>
>
>
>
>
> > The number I am give is epoch in milliseconds.
> > Mongodbisodateis int64 epoch time precision to milliseconds.
>
> > when I use it in mongoshell, it works fine.
> > tm: { $gt:new Date(1314536400000), $lt:new Date(1314547200000)} })
>
> > In myjavascript, None of the following works
> >
whereobj.tm=1314547200000
> >
whereobj.tm=new Date(1314547200000)
> >
whereobj.tm='ISODate("2011-08-28T15:49:35Z")'
>
> > Wondering how to query date field in mongo from nodejs.
>
> > On Nov 7, 2:13 am, Sam Millman <
sam.mill...@gmail.com> wrote:
>
> > > Prolly because that isn't really a valid timestamp.
>
> > > Using a converter I got more like:
>
> > > 1313351055
>
> > > For your date time.
>
> > > This might not be correct since it is only a rough estimation but still the
> > > time number you have provided is much much greater than a timestamp.
>
> > > On 7 November 2011 05:46, life0fun <
life0...@gmail.com> wrote:
>
> > > > Hi,
> > > > I have a timestamp field withisodatetype :
> > > >ISODate("2011-08-14T19:44:15Z").
> > > > When I query from mongo shell, it works if I use new Date(),
> > > > $lt:new Date(1314547200000)
> > > > However, if I am using int number, i.e., $lt: 1314547200000. it
> > > > fails.
>
> > > > new Date() in mongoshell producesISODate(), that why it works.
>
> > > > I am using mongo-node-native, new Date() injavascriptgives me JS