`Save and Close` button is disabled by data filter in Query Bar

I encounter strange behavior on the Save and Close button functionality on Chart dashboard. Button is disabled when I have the following filter in query bar:

{
    $expr:{
            $gte:['$ReportedDate', {$toDate:{$dateToString: { format: "%Y-%m-%d", date: new Date() }}}]
    }
}

However, change filter to the following allows me to save my changes:

{
    $expr:{
            $gte:['$ReportedDate', ISODate('2021-02-12')]
    }
}

Both filters return the same data needed but the former will not let me save. My goal is to present data which ReportedDate matches current date.

Hi @chanleong,

Welcome to MongoDB community.

Isn’t new Date() will return a date? Why do you need to convert it to string
?

{
$expr:{
$gte:[’$ReportedDate’, "$$NOW"
}
}

Will that work?

Thanks
Pavel

There are some known issues around validating queries with $expr in them, which is the reason the button is disabled. We’ll try to get this sorted soon, but you can do this without needing $expr. I presume it’s important that the date is set to the most recent midnight. In this case you could use a query like this:

{ ReportedDate: { $gte: new Date().setHours(0,0,0,0) } }

Another (easier) option is to use the Filters tab. Once you drag the field onto the tab, you can select the “Period” option and then “Current Day”.

HTH
Tom

3 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.