Mongodb aggregation uses pipeline to generate InvalidPipelineOperator.

I want to make a log analysis system based on mongodb. A single document is as follows:

{
    "_id" : ObjectId("5c6a14c4421aa97a4714b291"),
    "some":"data"
    "startTime" : ISODate("2019-02-18T02:13:24.244Z"),
    "endTime" : ISODate("2019-02-18T02:13:24.279Z")
}

because startTime is a millisecond time, I group to a second-based time, so I write the following code for conversion:

db.apiMonitor.aggregate([
    {
        $project:{
            groupField:"$startTime"
        }
    },{
        $project:{
            groupField:{
                $dateToString:{
                    format:"%Y-%m-%d %H:%M:%S",
                    date:"$groupField"
                }
            }
        }
    },{
        $project:{
            groupField:{
                $dateFromString:{
                    format:"%Y-%m-%d %H:%M:%S",
                    dateString:"$groupField"
                }
            }
        }
    }
])
The

process converts ISODate into a time string using $dateToString to remove millisecond information, and then reconverts it to ISODate via $dateFromString, but runs erratically as follows:

command failed: {
        "ok" : 0,
        "errmsg" : "Unrecognized expression "$dateFromString"",
        "code" : 168,
        "codeName" : "InvalidPipelineOperator"
}

can you explain what caused this error, or is there any other solution?

Jun.24,2022

the version of mongodb must be more than 3.6. can you use $dateFromString


what's the alternative? the production line server is 3.4.15, you can't let the operation and maintenance upgrade

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ead9ad-216a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ead9ad-216a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?