Number of orders placed between any two date ranges

PHOTO EMBED

Mon Jul 18 2022 01:39:20 GMT+0000 (UTC)

Saved by @surbhkrmkr #mongo #metabase

[
  {
    "$match": {
      "$and": [
        {
          "$expr": {
            "$gte": [
              "$Invoice_date",
              {
                "$dateFromString": {
                  "dateString": "2022-07-17T00:00Z"
                }
              }
            ]
          }
        },
        {
          "$expr": {
            "$lt": [
              "$Invoice_date",
              {
                "$dateFromString": {
                  "dateString": "2022-07-18T00:00Z"
                }
              }
            ]
          }
        }
      ]
    }
  },
  {
    "$group": {
      "_id": null,
      "count": {
        "$sum": 1
      }
    }
  },
  {
    "$sort": {
      "_id": 1
    }
  },
  {
    "$project": {
      "_id": false,
      "count": true
    }
  }
]
content_copyCOPY