[SERVER-23747] Error Get time difference between two dates in seconds Created: 15/Apr/16  Updated: 22/Feb/18  Resolved: 25/Apr/16

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 3.3.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: shibimukesh Assignee: Kelsey Schubert
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Calculating seconds between two dates error in mongodb

db.collection.aggregate({$project:{"dateDifference": { $subtract: [ ISODate("2015-05-30T10:01:58.000Z"),"$date"]}}})



 Comments   
Comment by Anurag Gupta [ 22/Feb/18 ]

how to calculate date difference in days?

Comment by Kelsey Schubert [ 25/Apr/16 ]

Hi shibish,

Yes, the aggregation pipeline supports the operations that you describe. From your responses, I do not see anything to indicate a bug in the MongoDB server. For MongoDB-related support discussion please post on the mongodb-users group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-users group.

Thank you,
Thomas

Comment by shibimukesh [ 18/Apr/16 ]

Respect Thomas Schubert,
Thanks for your response,
db.collection.aggregate({$project:{"dateDifference":

{ $subtract: [ ISODate("2015-05-30T10:01:58.000Z"),"$date"]}

}})

this was my query i need to take the difference between the date and time
in want to project the time less than 15 sec
and my clarification is that do $subtract aggregation will take the
differnce between time,
thanks in advance
with regards,
M.shibi

Best Regards,

*Shibi.M*Hadoop Developer

<http://www.ndottech.com/>

NDOT Technologies Pvt Ltd,
Block No 3,
1,2 & 3rd Floor,
Mullai Nagar,
Coimbatore - 641041.
Phone: +91 422-434-2518, 519

shibi.m@ndot.in

US : +1 (323) 982-8943
<https://www.facebook.com/ndotin>
<https://www.linkedin.com/company/ndot-technologies>
<http://twitter.com/ndottechnology>

<http://www.ndot.in/>Enterprise Mobility – CRM – ERP – Mobile – Web –
Software – Hire Team – Ecommerce

INDIA (HQ) - Singapore - United States - Dubai - Morocco – Spain -
Venezuela

DISCLAIMER:

The information contained in this message (including any attachments) is
confidential and may be privileged. If you have received it by mistake
please notify the sender by return e-mail and permanently delete this
message and any attachments from your system. Any dissemination, use,
review, distribution, printing or copying of this message in whole or in
part is strictly prohibited. Please note that e-mails are susceptible to
change. NDOT Technologies Pvt Ltd (including its group companies) shall
not be liable for the improper or incomplete transmission of the
information contained in this email.

On Fri, Apr 15, 2016 at 9:16 PM, Thomas Schubert (JIRA) <jira@mongodb.org>

Comment by shibimukesh [ 18/Apr/16 ]

db.collection.aggregate({$project:{"dateDifference":

{ $subtract: [ ISODate("2015-05-30T10:01:58.000Z"),"$date"]}

}})
this was my query i need to take the difference between the date and time and want to project the output as time less than 15 sec and my clarification is that do $subtract aggregation will take the differnce between time and date
thanks in advance

Comment by Kelsey Schubert [ 15/Apr/16 ]

Hi shibish,

Can you please clarify what the error is that you are seeing? Can you provide the output after running query in the description?

Thank you,
Thomas

Comment by shibimukesh [ 15/Apr/16 ]

how to calculate time difference in seconds for two dates

Generated at Thu Feb 08 04:04:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.