Forum Discussion

Rob Nunley's avatar
Rob Nunley
Brass Contributor
Mar 27, 2020

SharePoint Date/Time Filter

I have a SharePoint list with a large number of entries.  There is a Date/Time column in the following format: mm/dd/yyyy hh:mm.  I have need to filter the data between yesterday at 14:00 and today at 13:59.  I've search high and low but have not been able to find a solution.  Ideas?

 

Thanks!

  • Sudharsan K's avatar
    Sudharsan K
    Steel Contributor
    Hi,
    If you want to do it within the list, then try creating a computed column and make sure your condition of datetime is applied which will be true or false. Then you can try filtering the computed columns for values with true. Try using column formatting and apply the condition in the new column using column formatting. Please refer the below link for some samples using column formatting.
    https://github.com/SharePoint/sp-dev-list-formatting
  • Hi,
    Let's say the Date/Time column you have is ServiceDate, you could add a new calculated column to extract and store the time (use the below formula to get the time component and save it). Now, you can either filter directly with these 2 date and time columns or create a view and configure filter to show the items filtered using these 2 columns for the required range.
    Formula for the calculated column -
    TEXT(ServiceDate-DATE(YEAR(ServiceDate),MONTH(ServiceDate),DAY(ServiceDate)),"h:mm")

    Thanks.
    • Rob Nunley's avatar
      Rob Nunley
      Brass Contributor

      Swaminathan Sriram 

       

      Hi,

       

      Thanks for the response.  I have a time column now.  How would the filter look in the SP view? Seams I would need to use the [Today] function somehow to get yesterday's entries after 14:00 and then today's entries before 13:59.

       

      Thanks!

  • MickeyLea's avatar
    MickeyLea
    Copper Contributor

    Rob Nunley I know this is an old post, so this may not be needed by you any longer but could still help someone in the future who stumbles on this.....

    A simple solution: I like to use a filtered view for each year for any lists that have significant entries in them. I do this in a new view and then call the view whatever year I am using. I have an example here where I have done this using the Created column:
    Created
    is greater than or equal to
    1/1/2023
    AND
    Created 
    is less than or equal to 
    12/31/2023

    Gets me all of 2023.

    Looks like this in SharePoint:

    I do similar for 2022, 2021, etc to get the yearly views as needed and have the list not show the 14,000 items (which breaks now that we are online instead of on-prem 😉 ...).

Resources