Supporters of End User
Web

SharePoint: List filtering by date range

Item is currently unrated. Press SHIFT+ENTER to rate this item.1 star selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+ESCAPE to leave rating submit mode.2 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.3 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.4 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.5 stars selected. Press SHIFT+ENTER to submit. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.
Categories:SharePoint Designer; Site Manager/Power User; Libraries and Lists; Web Part; MOSS; WSS; 2007; 2010

 

Setting up multiple date filters to filter a list by a date range is possible out of the box in SharePoint 2010.

Using date filter web parts to send values to a lists parameters we can get the list to filter by a date range.

Setting this up is rather simple...

In your browser create a new page and add your populated list to it via the web parts options on the ribbons. For this example I'm just going to use my tasks list.

On the same page add a date filter webpart

2011-08-17-ListFilterByDate-01.jpg

From the arrow drop down that appears when you hover over the new date filter web part, select edit web part.

2011-08-17-ListFilterByDate-02.jpg

In the options pane that appears, change the Filter name to 'Start Date', and change the default value to 'offset from today : 30 days : Before today'. Then click ok.

2011-08-17-ListFilterByDate-03.jpg

Underneath that, add another date filter and change its filter name to 'End date', and change the default value to 'offset from today : 0 days : After today'. Then click ok.

2011-08-17-ListFilterByDate-04.jpg

Now save the page in your browser, then open the page up in SharePoint designer (SPD) - in design view.

2011-08-17-ListFilterByDate-05.jpg

Once opened in SPD, click on the list web part to select it, then in the ribbon click on the list view tools > options > parameters icon.

2011-08-17-ListFilterByDate-06.jpg

Add two new parameters, one called 'startdate' and another called 'enddate. Leave the parameter sources and default values as default and click ok when done.

2011-08-17-ListFilterByDate-07.jpg

The parameters on the list allow us a point for our date filters to pass their values to. Now we need to set up the connections between the list and the date filters.

Right click on the start date filter and click add connection. In the dialog that pops up change the dropdown value to 'Send filter values to', click next.

2011-08-17-ListFilterByDate-08.jpg

Ensure that 'connect to a web part on this page' is selected in the next dialog and click next.

2011-08-17-ListFilterByDate-09.jpg

Change the target action in the next dialog to 'Get parameters from' and click next.

2011-08-17-ListFilterByDate-10.jpg

In the next dialog, select 'Start Date' from the first box, and 'Startdate' from the second box and click next. Then click finish.

2011-08-17-ListFilterByDate-11.jpg

Go through the same process with the second date filter, but in the final step select 'End date' and 'Enddate' from the boxes.

2011-08-17-ListFilterByDate-12.jpg

Now we have our date filters feeding the list with its values but we still have to set up the filter on the list.

Click the list web part to select it, then in the ribbon click on the list view tools > options > filters icon.

2011-08-17-ListFilterByDate-13.jpg

The filter criteria box will popup. First add a rule 'Created > Greater than or equal to > [Start date]'.

2011-08-17-ListFilterByDate-14.jpg

Then add another clause 'Created > Less than or equal to > [Enddate]'. Click ok.

2011-08-17-ListFilterByDate-15.jpg

Now save the page and open it back up in your browser.

It will, by default, show all tasks created in the last seven days thanks to the default setting of the start date filter. Changing these filter will filter the list according to the date ranges set.

2011-08-17-ListFilterByDate-16.jpg

Comments

Prasad Prabhu

Is it possible to get it working with using SPD

Hi this is a very useful article. Thanks ! However The scenario I am working with does allow me to use SPD. Is there a way where in we could avoid usage of SharePoint designer and still get this range filter to function?

Posted 31-Jan-2012 by Prasad Prabhu
Clint

list filtering has a bug!

If you follow these instructions, you won't be able to click any list item and do view or edit item.  If you only need to view a list, then these instructions are perfect.  But, if you want to show a list with just general fields, allow someone to click an item and get all of the details of the item using "view item" then this doesn't work. 
 
Also, this causes the "export to excel" to export nothing.

Posted 03-Feb-2012 by Clint
guru

not working for other fields with date format

I have another field (submission date)calculated column return type date time i used to filter the same.. it did not work if I use created then it works like a charm why? whats the diffrence between my column and created?

Posted 11-Feb-2012 by guru
Bilal

when the date filter parameters are not entered (empty)?

Hi, thanks for the post, its really helpful. I created a site page with multiple list filter(text,choice,date...) web parts and a list view web part. I managed to make text and choice filters work in browser. But for the date filter, browser was not enough. Because, it just uses an exact match for the date filter. I needed to use a Greater Than or Equal approach. So, I used SPD. Now, its working But still I have a problem. When I enter a date for the date filter, the original list is filtered correctly. Then, I enter text for the text filter, and the filtered list is filtered correctly. But after that, When I CLEAR the date (I mean, I don't want to filter by date ), the original list with the text filter should be shown. But there is still date+text filtered list! I hope I could tell the problem. I'm a beginner, Thanks again!

Posted 10-May-2012 by Bilal
Avinash Badgujar

Avinash Badgujar

Very helpful thanks.

Posted 15-Oct-2012 by Avinash Badgujar
Anderson

SP2013

Any idea how to get this working in 2013? Looks like they completely gutted SPD 2013 and doesn't have tool bars like that anymore. What does the code look like for a page where this has been done?

Posted 26-Feb-2013 by Anderson
Michael Carpenter

Thank you

Thank you for this article, it was very helpful. 

Posted 23-May-2013 by Michael Carpenter
Daniel Charlton

SP2013

For SharePoint 2013, you need to insert your list view web part in SPD as a Data View. Then you will get the additional ribbon options that are listed above. However, I have found that the filter bindings do not seem to apply as they should. If I change the start date to some earlier time, I will not get earlier items to appear until I also change the end date filter. Moving the range forward in time is even more problematic - you have to set the end date to a later time, then set the start date and then change the end date filter again before it returns the proper results. It seems as though the connection is only binding one of the two values at a time when it applies the filter. Any ideas on how to improve this?

Posted 04-Sep-2013 by Daniel Charlton
krishna

Problem while filtering

After filtering condition is done on the list view , the data part of the list view shows the following error. Can any one help me out. There are no items to show in this view of the "ConferenceRequestMasterList" list.

Posted 30-Sep-2013 by krishna
Shahin

Thank you

So helpful. Thanks a lot....

Posted 29-Oct-2013 by Shahin
venki

SP2013

this is not working for 2013 and i added dataview webpart and gave source as my list. the filter webpart configured as you said but :( not working

Posted 19-Dec-2013 by venki
Ale

Export to excel

Is there any chance to export this data to excel?

Posted 13-Feb-2014 by Ale
Ale

Export to excel

Is there any chance to export this data to excel?

Posted 13-Feb-2014 by Ale

Notify me of comments to this article

E-mail:
   

Add Comment

Title:

 
Comment:
Email:

   


Name:

 
Url: