Json-server: Filter by date range

Created on 13 Sep 2018  路  5Comments  路  Source: typicode/json-server

Is it possible filter by date range? I have 2 fields from_date and to_date, is there any way to filter by range?

Most helpful comment

Is it possible filter by date range? I have 2 fields from_date and to_date, is there any way to filter by range?

Yes, you can use: dateFieldName_gte and dateFieldName_lte
Enjoy!

All 5 comments

Is it possible filter by date range? I have 2 fields from_date and to_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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Isanderthul picture Isanderthul  路  3Comments

AdamCook44 picture AdamCook44  路  3Comments

casvil picture casvil  路  4Comments

TXRRNT picture TXRRNT  路  4Comments

melnikovic picture melnikovic  路  3Comments