[mongodb-user] Difference In Dates in Days - Cannot Subtract String From String Error
Difference In Dates in Days - Cannot Subtract String From String Error
Tue, 10 May 2016 07:26:02 -0700 (PDT)
I am trying to query all results but subtracting the current date from a
date stored in the database, and then comparing it to a stored number. The
code I have looks like this and is run through the aggregation from work:
$ops = array(
'$redact' => array(
'$cond' => array(
'if' => array(
'$gte' => array(array('$subtract' => array( 'new
ISODate()' , 'new ISODate(last_interacted_date)')), 'reminder_interval')
'then' => '$$KEEP',
'else' => '$$PRUNE'
I get the following error message:
Uncaught exception 'MongoResultException' with message 'localhost:27017:
cant $subtract aString from a String'
How can I cast or subtract these as dates and get the days in between the
dates to compare to another var
You received this message because you are subscribed to the Google Groups "mongodb-user"
For other MongoDB technical support options, see:
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
To view this discussion on the web visit
For more options, visit
for more updates.