Filtering with between in Supabase
I'm trying to useList while filtering a date column. The format of the date in this column is YYYY-MM-DD. When trying to filter using the "between" operator, I get the following error from Supabase:
Here's my code:
authProvider.ts:186 Error: Operator between is not supportedauthProvider.ts:186 Error: Operator between is not supportedHere's my code:
const [quarterStart, setQuarterStart] = useState('');
const [quarterEnd, setQuarterEnd] = useState('');
// Calculate start and end dates of the current quarter
useEffect(() => {
const startOfMonth = dayjs().startOf('quarter').format('YYYY-MM-DD');
const endOfMonth = dayjs().endOf('quarter').format('YYYY-MM-DD');
setQuarterStart(startOfMonth);
setQuarterEnd(endOfMonth);
}, []);
const { data, isLoading: brokerageReportsIsLoading } = useList({
resource: 'brokerage_reports',
filters: [
{
field: 'reportDate',
operator: 'between',
value: [quarterStart, quarterEnd], // If today is April 1st 2024, this will return all reports from Q1 2024 (January 1st 2024 - March 31st 2024)
},
],
});
const brokerage_reports_last_q = data?.data ?? [];
console.log(brokerage_reports_last_q);const [quarterStart, setQuarterStart] = useState('');
const [quarterEnd, setQuarterEnd] = useState('');
// Calculate start and end dates of the current quarter
useEffect(() => {
const startOfMonth = dayjs().startOf('quarter').format('YYYY-MM-DD');
const endOfMonth = dayjs().endOf('quarter').format('YYYY-MM-DD');
setQuarterStart(startOfMonth);
setQuarterEnd(endOfMonth);
}, []);
const { data, isLoading: brokerageReportsIsLoading } = useList({
resource: 'brokerage_reports',
filters: [
{
field: 'reportDate',
operator: 'between',
value: [quarterStart, quarterEnd], // If today is April 1st 2024, this will return all reports from Q1 2024 (January 1st 2024 - March 31st 2024)
},
],
});
const brokerage_reports_last_q = data?.data ?? [];
console.log(brokerage_reports_last_q);