Re: Comparing dates inside of mapreduce

From: Asya Kamsky <asya@xxxxxxxxxxx>
To: mongodb-user <mongodb-user@xxxxxxxxxxxxxxxx>
Date: Mon, 25 Apr 2016 20:37:19 -0400
Why ads?
Are you sure you want to be using mapReduce?   Most things that people
do in mapReduce can be done faster in aggregation framework.   Can you
give a bit more context for your problem?  Are you emitting different
values depending on relationship between "created" and "start"?

Asya


On Mon, Apr 25, 2016 at 5:01 PM, Vegar Vikan <vegar@xxxxxxxxxx> wrote:
I posted this question on stackoverflow, but it didn't get any attention, so
I try here as well...

I have a map function in a mapreduce query where I try to compare a couple
of dates.

Lets say that the documents contains a property 'Created' with type ISODate:

{
  Created: ISODate("2016-01-01T12:00:00.000+0000")
}

In my map/reduce method, I pass a date through the scope:

{
   start: ISODate("2015-01-01T12:00:00.000+0000")
}

and in my map method, I print out the following

function() {
   print(this.Created);
   print(start);
   print(this.Created > start);
}

I'll get the following output in my log:

2016-04-25T16:19:04.921+0200 I -        [conn129]
ISODate("2016-01-01T12:00:00.000+0000")
2016-04-25T16:19:04.922+0200 I -        [conn129] Sat Jan 01 2015 13:00:00
GMT+0100 (Vest-Europa (normaltid))
2016-04-25T16:19:04.922+0200 I -        [conn129] false


Why is the dates printed differently?
How can I compare the start-date with the created date?

regars,
-Vegar

--
You received this message because you are subscribed to the Google Groups
"mongodb-user"
group.

For other MongoDB technical support options, see:
https://docs.mongodb.org/manual/support/
---
You received this message because you are subscribed to the Google Groups
"mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit
https://groups.google.com/d/msgid/mongodb-user/9fc028b4-3f48-4dbb-b76b-9b017eec9adc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



-- 
Asya Kamsky
Lead Product Manager
MongoDB
Download MongoDB - mongodb.org/downloads
Free MongoDB Monitoring - cloud.mongodb.com
Free Online Education - university.mongodb.com
Get Involved - mongodb.org/community
We're Hiring! - https://www.mongodb.com/careers

-- 
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
--- 
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/CAOe6dJB06Wvz5WJ%3DQAY4moQBf93PkBb_CKFPmSOh_iTpXSNoiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Why ads?