How to filter a view based on the current date [Today]

If you ever need to filter a view based on calculation from Today’s date, it is pretty simple in SharePoint 2010. All you need is SharePoint Designer.

 

  1. Create a view through the SharePoint UI and set the filter to use [Today] as the filter value.
  2. Open the view in SharePoint Designer
  3. View the source code of the view. You will see the CAML used to create the view right within the source. You should see something like this:
    <Where><Leq><FieldRef/><Value><Today/></Value></Leq></Where>
  4. You can then calculate the number of days from the current date by using the OffsetDays property. The following example will filter the view to show all items within the next 30 days:
    <Where><Leq><FieldRef/><Value><Today OffsetDays=”30”/></Value></Leq></Where>
  5. Save the page and check out your new view.