Forum Discussion

NThoman's avatar
NThoman
Iron Contributor
Mar 01, 2024

Submit-PnpSearchQuery Filter on Date

$SearchQuery = "ReportDate=1900-01-01 Path:" + $SiteURL
Submit-PnPSearchQuery -Query $SearchQuery -All -SortList @{Created="Descending"}

 

How do you format the query string to return results with NULL dates in SharePoint on the field ReportDate?

  • NThoman What is the issue with search query you are using? Is it throwing any error or is it not returning the expected search results?

     

    Try using date range once like below: 

     

    ReportDate>=1900-01-01 AND ReportDate<=1900-01-01

     

    Use correct managed property name of your date column.

     

    References

    1. SharePoint CSOM Query Keyword Filter On Date Time Type Column 
    2. Filtering query string results by date range 

    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

    • NThoman's avatar
      NThoman
      Iron Contributor
      I am not getting any results but there should be thousands. The field was first created with no spaces. The renamed with spaces.
      ReporDate —> Report Date

    • NThoman's avatar
      NThoman
      Iron Contributor
      ReportDate>=1900-01-01 AND ReportDate<=1900-01-01 did not work. Got no results.
      • NThoman ReportDate is list/library level column or site level column?

         

        I think you are trying to use the internal name of your list/site column - which does not work with search queries.

         

        You have to use the name of managed property associated with your column. If you are using site column, managed property will be created automatically for you. But if you are using list/library level column, you have to use the existing managed property and map it with the crawled property associated with your list column.

         

        Check: Showing list column in search results 


        Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources