I have a requirement to fetch the news items in between the fromDate and toDate. fromDate and toDate need to pass as a parameter so i am unable to forming the query. for your reference please find the below screenshot.
The parameters that are passed in are used to build a predicate and fired off for search results from the Search API. The OOTB parameters allow for very powerful and fast queries for data but are limiting by a key factor. It does not support filter by date and sorting, so you cannot control the order in which your results are returned. In a recent implementation, we had to add date filter fromdate,todate and sorting to allow us to retrieve data sorted by date in given date range.
Most standard sorting will work, but it likely won't give you the desired result if you're trying to sort something like a date. To do this, you will need to convert your date field to a string-sortable friendly value. My recommendation is to create a computed index for your date fields to store the value in ticks.
You can find the full implementation for the ExtendedSearchQuery in a gist here: ExtendedSitecoreQuery.
Hopefully, this helps.