json-server
json-server copied to clipboard
Filter by date range
Is it possible filter by date range? I have 2 fields from_date
and to_date
, is there any way to filter by range?
Is it possible filter by date range? I have 2 fields
from_date
andto_date
, is there any way to filter by range?
Yes, you can use: dateFieldName_gte and dateFieldName_lte Enjoy!
This only works for intersection. Meaning from_date =< to_date. dates from 2017 up to 2018. I am not sure if json-server support cases where you want to exclude a date range. Meaning all dates not in from_date to to_date. ex. dates up to 2017 or dates bigger then 2018.
Whats the date format to use for filter?
gte and lte is not working on date filter I am want to find data between 24/08/2008 to 24/08/2012 so for between it is not working it is working for equal only any solution please
@ladaniavadh You'll need to store your date in ISO 8601 format (e.g. "YYYY-MM-DD...") in order to be able to sort and filter properly.
This is standard practice for many reasons, including that it allows simple lexical sorting, and avoids issues with localised date formats.
@ciw1973 @realtica Is it possible to filter my month in json-server
? if yes then which format to use?
Is it possible filter by date range? I have 2 fields
from_date
andto_date
, is there any way to filter by range?Yes, you can use: dateFieldName_gte and dateFieldName_lte Enjoy!
Doesn't work for me on dates.
Is it possible filter by date range? I have 2 fields
from_date
andto_date
, is there any way to filter by range?Yes, you can use: dateFieldName_gte and dateFieldName_lte Enjoy!
and initialize the dateFieldName_gte property and dateFieldName_lte property by undefined instead of an empty string, by setting the value equal to undefined, the query will not include that property, which allows you to get data when you don't select the date.
Thanks