Can Any one help me here to indentify what could be the issue here in MongoDb Aggregation Query?

Viewed 30

** I am trying to extract all the documents which has date2 greater than date one , but i want to compare this in Date formate and not in string formate and mongo version is 5.0**

**NOTE : This is the new script and these all are under aggregate[] **

    {
        $match : 
        {
                "policyStartDate":{$ne: ""},
                "deviceSoldDate" : {$ne: ""}
        }
    },
    {
        $project : 
        {            
            "polStartDate": {
                      "$dateFromString": {
                        "dateString":{ $replaceAll: { input: "$policyStartDate", find: "/", replacement: "-" }}
                     }
                },
            "devSoldDate": {
                      "$dateFromString": {
                        "dateString":{ $replaceAll: { input: "$deviceSoldDate", find: "/", replacement: "-" }}
                     }              
        }
    }},
    {
        $match : 
        {
                partnerId: { $in: ["MYSAMSUOEMNA01","HKSAMSUOEMNA01","TWSAMSUOEMNA01","THSAMSUOEMNA01","PHSAMSUOEMDG01","VNSAMSUOEMNA01"
                                    ,"PHSAMSUOEMCF01","IDSAMSUOEMCF01","IDSAMSUOEMNA01","PHSAMSUOEMNA01","MOSAMSURETNA01"]
                                            },
                "polStartDate": {
                        $lt: this.devSoldDate
                    }
        }
    }
    
]) ```

**GIVING ME THIS ERROR**

**{
    "message" : "Unrecognized expression '$replaceAll'",
    "operationTime" : Timestamp(1662366320, 1),
    "ok" : 0,
    "code" : 168,
    "codeName" : "InvalidPipelineOperator",
    "$clusterTime" : {
        "clusterTime" : Timestamp(1662366320, 1),
        "signature" : {
            "hash" : "w3gSNlRYCN9gCDCk7yRXPNCXDrk=",
            "keyId" : NumberLong("7102798729786163202")
        }
    }
} **
0 Answers
Related