每小时对isodate进行聚合查询,返回错误

时间:2019-02-12 12:14:15

标签: mongodb

下面提到的查询无法按小时汇总记录。 出现错误

  

“ errmsg”:“例外:FieldPath'+0530'的开头不是$”,

db.st_events.aggregate([{
        "$project":
            {
                "yearMonthDayUTC": {"$dateToString": {"format": "%Y-%m-%d", "date": "$created"}},
                "y": {"$year": "$created"},
                "m": {"$month": "$created"},
                "d": {"$dayOfMonth": "$created"},
                "h": {"$hour":  {
                "date":  "$created",
                "timezone": "+0530"
        }},
                "company_id": "$company_id",
                "session_id": "$session_id",
        "created": "$created"
            }
        },
        {
            "$match": {
                "company_id": "51",
                "yearMonthDayUTC": '2019-02-11'
            }
        },
        {
            "$group": {
                "_id": {"year": "$y", "month": "$m", "day": "$d", "hour": "$h", "company_id": "$company_id","created":"$created",
                        "session_id": "$session_id"}, "count": {"$sum": 1}
        }

        }]
    )

0 个答案:

没有答案