Date filter doesn't work when using SDK
Bug description :
When applying date filter to a date property on createChart method, resulted charts are incorrect (Zeros or blank charts).
Here is the filter I'm passing in the createChart method :
filter : { dateStart: new Date('2024-03-19') }
This filter should result in one document in the target collection and the property dateStart is recognized as Date type in either mongoDB charts web UI and in MongoDB Compass.
Expected behavior :
When passing date based filter to the createChart method, the filter should apply correctly and the display data should reflect the result of the same query made via compass or MongoDB charts UI.
Hi @thomasViabeez
I think the problem here might be that the date does not match exactly because of the minutes in the date. If you want an exact match you need to see what the the date value in the mdb document that you are targeting. Like for example, this filter works for a single date document from my db collection:
filter: { dateStart: new Date("2024-03-19T16:00:00.000")}
If you do not want to put precise dates, you can use a 24 hour range:
filter: {
$gte: new Date("2024-03-19T00:00:00.000"),
$lte: new Date("2024-03-19T23:59:59.999")
}
I hope that helps
Closing this as there is no activity and there should be no issue around date filters in the SDK. More details in the community post.