Finding all rows in range of two dates #4812
-
I would like to query all rows between timestamp1 and timestamp2 I have tried this: const date1: Date = new Date();
const date2: Date = new Date();
date2.setDate(date2.getDate() + 1) // just for example so that we do not have the same date twice
const dateString1: string = date1.toISOString();
const dateString2: string = date2.toISOString();
const {data} = await supabase.from('News_items').select('*').rangeLt('publish_date', [dateString1, dateString2]) However this will complain that The docs here gives this example: const { data, error } = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeLt('population_range_millions', [150, 250]) What would be the valid way of finding all rows between 2 date? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
You should be able to do it with chaining .gte, .lte. |
Beta Was this translation helpful? Give feedback.
-
I try to get data with a range 'startDate' & 'endDate'
But, not working as expected. This query will return all data "greater than startDate" or "less than endDate". |
Beta Was this translation helpful? Give feedback.
You should be able to do it with chaining .gte, .lte.
Edit: It is my understaning .rangeLt compares a range type against another, versus a single value, but I'm not that familiar with PostGres ranges and the translations postgrest.js does on converting .rangeLt to postgrest API call.