Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to use the Created column in my keywoard query, like this:

  KeywordQuery query = new KeywordQuery(site);
  query.QueryText = "ContentType=\"Vraag\""; // AND TaskStatus<>Voltooid";
  query.ResultTypes = ResultType.RelevantResults;
  query.SelectProperties.Add("Title");
  query.SelectProperties.Add("Path");
  query.SelectProperties.Add("OrderNumber");
  query.SelectProperties.Add("Created");

  ResultTableCollection resultsCollection = query.Execute();
  ResultTable results = resultsCollection[ResultType.RelevantResults];

  DataTable result = new DataTable();
  result.Load(results, LoadOption.OverwriteChanges);

But I can't find how to use the Created datetime field. I know there is a Write property that can be used, but that is the modified datetime.

Does anyone know how to use the Created datetime field in a KeyWordQuery?

share|improve this question

2 Answers 2

This worked for me.

As Amit suggested, create a new managed property (CreatedDate) of type Date and Time.

Map it to these Crawled Properties

  1. Basic:15(Date and Time)
  2. ows_Start_x0020_Date(Date and Time)
  3. ows_StartDate(Date and Time)
  4. Office:12(Date and Time)
  5. creationdate(Date and Time)

And select Include values from a single crawled property based on the order specified

Hope this helps.

share|improve this answer
    
+1 - this answer helped me a lot, thanks. –  DeeMac Jun 28 '12 at 13:51

In the Search administration, You can create a new managed property (CreatedDate for example) and map it to ows_Created crawled property.

After a crawl, you should be able to use it like you need:

query.SelectProperties.Add("CreatedDate");
share|improve this answer
    
I have actually tried this and I get null back in Created Date. Also, in the SharePoint search results page - created date is included? –  SteveCl May 2 '12 at 13:27
    
Did you do a crawl after creating and mapping new managed property? –  Amit Kumawat May 2 '12 at 15:05
    
Yep - certainly did! –  SteveCl May 2 '12 at 20:10
    
The search clearly has the created date though - to be able to show it in the search results page - so how can we get a handle on it I wonder!!!!? –  SteveCl May 2 '12 at 20:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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