Metabase MongoDB custom date filtering

Metabase is generating this query :

[{"$group":{"_id":{"openedAt~~~month":{"$let":{"vars":{"parts":{"$dateToParts":{"date":"$openedAt"}}},"in":{"$dateFromParts":{"year":"$$parts.year","month":"$$parts.month"}}}}},"count":{"$sum":1}}},{"$sort":{"_id":1}},{"$project":{"_id":false,"openedAt~~~month":"$_id.openedAt~~~month","count":true}},{"$sort":{"openedAt~~~month":1}}]

I want to add two date filter Start Date & End Date which will work on openedAt variable, how can I do that? Also it should be optional variable. kindly help, thanks.

Hi @kayumuzzaman
Try doing a filter using between, since it would likely make it a little easier to understand where to place the variables. And then have a look here:
https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html

not sure how to do it using mongo, i have done it in postgres.

Having an issue in mongo. Did you find out the fix?

@Anum So instead of just writing a comment like that, which helps no one, then you could provide a link to the forum topic you have: Optional date clause in mongo db query
Try to help making this forum better. And when you find the answer to a question, then post the answer instead of just leaving the topic hanging.