Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
MongoDB aggregate ERROR('cant $subtract a date from a string')
  • I'm implementing a requirement to group by time and query the maximum values within each grouping, but mongoDB returns an error
db.getCollection('Power').aggregate([
     {$match:{
        iotId:"57141305840d8ea11f13",
        createdTime: {'$gte': ISODate("2020-03-11T00:00:00Z")  ,'$lt':ISODate("2021-03-12T00:00:00Z")}
    }},
    {$group: {
        _id: {
            $subtract: [
                { $subtract: [ "$createdTime", new Date("1970-01-01") ] },
                { $mod: [
                    { $subtract: [ "$createdTime", new Date("1970-01-01") ] },
                    1000 * 60 * 5 
                ]}
            ]
        },
        Power: {'$max': '$Power'},
        timelist: { '$push': '$createdTime'} 
  }},
    {$project: {
            timelist: 1
    }}
]
)
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!