3

In SP 2013 on-prem, I am using display template and a list to show alerts on the front page of the intranet. I want the alerts to be showed from the list when the list item has a start date that is less than or equal to today, and end date that is greater than or equal to today.

This is my query, where Date01 is start date, and date02 is end date:

path:{Site.URL}  ContentTypeId:0x0100277BL3829BB9VIC110PXT410125FCC83* Date01<={Today}  Date02>={Today}

My query works, but the only issue is that Date02 is of type Date and Time, and KQL query does not care about time. I want {Today} to behave like DateTime.Now, while it behaves like Date.Now

How can I do that ? Please advice.

2 Answers 2

3

With KQL it is only possible to query by day ranges. If you want to use something like DateTime.Now you will have to use FQL instead, see link

4
  • Can FQL be used in content search web part?
    – Ilyas
    Jan 11, 2016 at 20:25
  • 1
    Only via injecting it as a refinement filter. Doable with javascript, but require some fiddling. Jan 11, 2016 at 21:29
  • That sounds a bit complicated :). I ended up running the logical part of scheduling as javascript statements in the Display templates.
    – Ilyas
    Jan 14, 2016 at 10:14
  • you can pass the current date to the KQL as a querystring parameter from javascript with document.location; the drawback of this workaround is the page gets refreshed on some (older) browsers
    – dc2009
    Apr 16, 2019 at 8:16
0

I know this is old but I used now() which returns the current date/time as DateTime object.

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.