How to filter table by date value?

Hey guys,

Probably a simple answer to this question, but I'm running an app with a Table in it connected to a Postgres database. I've already been able to filter the database with text input fields as such:

and ({{ !textInput3.value }} OR league_access_code LIKE '%' || {{ textInput3.value }} || '%')

However, when I try to use the date value picker, I get an error.

and ({{ date1.value == ""}} OR order_placed = {{ date1.value }})
and ({{ !date1.value }} OR order_placed = {{ date1.value }})

The error is: invalid input syntax for type date: ""

What can I do to fix this? Thanks.

1 Like

Are you using Query with JSON as a resource? Also, is it possible for you to share some screenshots? Is it possible also share the formatting you are using for date? This is something I have implemented when there is no date "selected" for the query -
WHERE status != 'Cancelled' AND ((updated_on >= {{valueDateRangeFilter2.value.start}} AND updated_on <= {{valueDateRangeFilter2.value.end}}) OR ({{valueDateRangeFilter2.value.start == ''}} AND {{valueDateRangeFilter2.value.end == ''}}))

:thinking: I wonder if you could also pass a default date since it will be ignored anyway, something like:

and ({{ !date1.value }} OR order_placed = {{ date1.value || moment().format() }})
1 Like

That was the solution! My code is posted below for any one experiencing a similar issue:

Note that this is just part of my SQL query that follows the WHERE clause.

and ({{ date1.value == ''}} OR order_placed = {{ date1.value || moment.calendarFormat}})