Datetime filters in Keyword Query Language

Hello all.

I'm trying to build an anniversaries webpart using search. I created a HireDate managed property which is tied to the People:SPS-HireDate profile property. I can do a search where HireDate is a certain date (eg HireDate="11-26-2012"). However, I need to get results where HireDate's month and day are today (eg HireDate:"11-26*"). Of course, it's not that easy. I've been looking into the datetime syntax but I can't get it working.

Any ideas? Thanks in ad

November 26th, 2013 3:21pm

One of the most common problems working with managed properties based on search is whether the managed property was created as a DateTime value or a text value.  The common thing is to create them as a text.  If HireDate is a text property I would expect what you have above would work.  But if its a datetime property it won't since datetime has no concept of a wildcard.  What data type is HireDate?
Free Windows Admin Tool Kit Click here and download it now
November 26th, 2013 3:37pm

Understood. It's a DateTime.
November 26th, 2013 3:39pm

Hi,

The wildcard operator (*) is supported for text property values which the property is stored in the full-text index.

For numerical property values, which include the Integer, Double, and Decimal managed types, the property restriction is matched against the entire value of the property. I think it is likewise the DateTime type.

For your information:

Keyword Query Language (KQL) syntax reference

http://msdn.microsoft.com/en-us/library/ee558911.aspx

Thanks.

Free Windows Admin Tool Kit Click here and download it now
December 3rd, 2013 8:16am

You can't use the wildcard operator with a datetime property, it will only work with a text property.  You'll need to map another property of type text if you want to do the search you are specifying.
December 3rd, 2013 2:12pm

Hi,
I propose you add two hidden properties which are set with code, and which contain the month and day. Probably the easiest.

Or, generate an OR query which limits per each date backwards. Then it's up to you how many years back you want to go before the query get's too big.

Or read all profiles and scan the fields...not using search with some cache logic.

Thanks,
Mikael Svenson

Free Windows Admin Tool Kit Click here and download it now
December 3rd, 2013 5:36pm

I like option #1. I've been noodling on how to programatically update those values. Not sure the best option given that the values may get synced from AD eventually. For the time being, I'm reading the profiles and caching matched users.
December 3rd, 2013 5:44pm

Did you ever get this working?  I'm trying to do a similar thing with SharePoint 2013 SEARCH.  I created a managed property which is of type TEXT and mapped it to the hire date (so that I can do wild card SEARCH). However, not able to get the desired results.
Free Windows Admin Tool Kit Click here and download it now
July 16th, 2015 9:47am

Hi,

What kind of queries are you doing and what do you want to achieve?

July 16th, 2015 9:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics