How do I query against the month portion of a SharePoint Column in a Display Template?

I've added a Content Search Web Part (CSWP) to my page and I need to restrict the number of items returned from my query because the search template has a limit of 50 results and the items I want are returned in positions 51-59. I want to query a date field in the list against today's date and if the months are equal I want to return the item.

my query text looks like this

Path:"https://someurl.com" MONTH(EmployeeHireDate)=MONTH({Today})

it returns 0.


I don't think you have those functions (e.g., MONTH) available in the query language. Could you do something like

Path:"https://someurl.com" EmployeeHireDate>{Today-30}
  • The only way that would work is if I did EmployeeHireDate>{Today-30} and EmployeeHireDate<{Today+30} and then hope that in the 60 days the query covers it doesn't return more than 50 people.
    – Smitman
    Apr 25 '16 at 13:03

Is it absolutely necessairy for you to show all results? You can add paging to the CSWP as well. Combine that with some smart sorting and users should be ok with 50.

If you don't mind styling yourself, you can also increase the number of results returned to you by using a REST API call instead, this will increase the max amount of returned results to 500 instead of 50.

With a little "hack" you could even force the standard CSWP to display more than 50 as well, but I wouldn't recommend doing that.

  • I only want to show results for the current month. The problem is I can't narrow the query enough to return less than 50 results at a time so when the item template loops through the results it never gets to the current month in the 50 that were returned. The current month starts at item 51-59 (figures, right?).
    – Smitman
    Apr 25 '16 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.