Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter by date range #851

Open
avxkim opened this issue Sep 13, 2018 · 8 comments
Open

Filter by date range #851

avxkim opened this issue Sep 13, 2018 · 8 comments

Comments

@avxkim
Copy link

avxkim commented Sep 13, 2018

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

@realtica
Copy link

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!

@elpddev
Copy link

elpddev commented Aug 11, 2019

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.

@felizardo-felipe
Copy link

Whats the date format to use for filter?

@ladaniavadh
Copy link

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

@ciw1973
Copy link

ciw1973 commented Apr 22, 2020

@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.

@whoafridi
Copy link

@ciw1973 @realtica Is it possible to filter my month in json-server ? if yes then which format to use?

@matronator
Copy link

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!

Doesn't work for me on dates.

@ilyassouK
Copy link

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!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants