KQL - Keyword Query Language - Date Time in Queries




KQL - Keyword Query Language - Date Time in Queries - Date Time Managed Property

KQL provides the datetime data type for date and time. The following datetime formats are supported in queries:
  • YYYY-MM-DD
  • YYYY-MM-DDThh:mm:ss
  • YYYY-MM-DDThh:mm:ssZ
  • YYYY-MM-DDThh:mm:ssfrZ
Below are the examples:

EndDate Equals to Selected Date: 
EndDate=2015-01-01
EndDate=2015-01-01T12:00:00

EndDate between two dates
EndDate=2015-01-01..2015-01-07

EndDate less than than selected date:
EndDate&lt;=2015-01-07 or EndDate<=2015-01-07 
EndDate&lt;=2015-01-07T12:00:00 or EndDate<=2015-01-07 

EndDate greater than selected date:
EndDate&gt;=2015-01-07 or EndDate>=2015-01-07 State:"Active"
EndDate&gt;=2015-01-07T12:00:00 or EndDate>=2015-01-07T12:00:00 

The KQL Query looks like:

<?xml version="1.0" encoding="utf-8" ?>
<QueryPacket xmlns="urn:Microsoft.Search.Query" Revision="1000">
<Query domain="QDomain">
 <SupportedFormats><Format>urn:Microsoft.Search.Response.Document.Document</Format></SupportedFormats>
 <Context>
  <QueryText language="en-US" type="STRING" >EndDate&lt;=2015-01-07T12:00:00 </QueryText>
 </Context>
<Properties><Property name="EndDate" /><Property name="Rank" /><Property name="Title" /><Property name="Author" /><Property name="Size" /><Property name="Path" /><Property name="Description" /><Property name="Write" /><Property name="HitHighlightedSummary" /><Property name="HitHighlightedProperties" /></Properties><SortByProperties><SortByProperty name="Rank" direction="Descending" order="1"/></SortByProperties>
 <Range><StartAt>1</StartAt><Count>500</Count></Range>
 <EnableStemming>false</EnableStemming>
 <TrimDuplicates>true</TrimDuplicates>
 <IgnoreAllNoiseQuery>true</IgnoreAllNoiseQuery>
 <ImplicitAndBehavior>true</ImplicitAndBehavior>
 <IncludeRelevanceResults>true</IncludeRelevanceResults>
 <IncludeSpecialTermResults>true</IncludeSpecialTermResults>
 <IncludeHighConfidenceResults>true</IncludeHighConfidenceResults>
</Query></QueryPacket>






Comments

Popular posts from this blog

Create and Deploy custom copilot to SharePoint Site (Part 2)

Create and Deploy custom copilot to MS Teams and SharePoint Site (Part 1)

Copilot Announcements from Microsoft Build 2024