SharePoint Date Filter: Filtering a List by Greater Than or Equal to Date
Guest Author: Mark Rackley
Update: A comment was posted asking if Mark had any luck using two date part filters between the "Start" and "End" dates. Mark added an update, at the end of this article, with his solution.
So, I was doing some playing around with mashups in SharePoint. I was seeing what I could do to create pages a little more useful than you get using vanilla SharePoint without having to crack open Visual Studio.
One of the things I wanted to do was display a SharePoint list on the screen and add a filter to the screen that would allow a user to filter the list with a date field value greater than or equal to whatever a user entered. Sound’s simple right? Should be easy? Well, I dropped my SharePoint list on a page, dropped a Date Filter on the page (this is an Enterprise feature by the way), connected the filter to the list and… I simply could not find a way to make the filter work as anything but a “Date equal to” filter. That’s not really very useful for most real world applications right?
Well, I reached out to the queen of out-of-the-box web parts Laura Rogers (@WonderLaura) to ask her how to do this, and she had not yet tried. “Wow” I thought. “Here’s my chance to teach Laura something.” She also indicated that this is a fairly common question.
So, after playing around I was able to fairly easily come up with a functional solution using SharePoint Designer. Now, before you jump on my case about using SharePoint Designer even though I’ve clearly stated you should not use it on your production servers, let me point out that by following the steps below you can export the web part created in SharePoint Designer and drop that web part on another page. Thus, allowing you to develop in SharePoint Designer without breaking any of the development standards I have previously put in place.
Without further adieu, the steps we will take are as follows:
- Convert List View to XSLT Data View
- Create a Parameter for the Data View
- Filter the Data View Using the Parameter
- Drop Date Filter Web Part on Page
- Connect Parameter on Data View to Date Filter
The Real World Scenario
Okay, here’s the situation. I have an Issues list. This list has a “Due Date” field which indicates when the issues have to be resolved by. I want to view all of the issues that are due on or after date ‘x’. Make sense? The quick and dirty non-user friendly approach would be to create a view of the list and hard code the date range in there. That’s not really useful or powerful though is it? I want to allow other users to be able to dynamically filter on the list and show those dates. Yes, I could also sort by due date, but is that really feasible or user friendly when the list grows to have thousands of entries?
Here is the solution I came up with.
Convert List View to XSLT Data View
First thing we need to do is get our Issues list on a page and convert it to an XSLT Data View. Doing this gives a lot of functionality we need in SharePoint including:
- The ability to export/import the web part
- The ability to manually modify the XSLT for the web part
- The ability to create and modify parameters for the web part
So, let’s get started. Create a blank Web Part Page in SharePoint and open up that page in SharePoint Designer.

Click on “Click to insert a Web Part” which will bring up the web part list in the right side panel if it is not already there. Find your list in question (Issues List in my case) and drag and drop it into the page.
Now, right click on the List and select “Convert to XSLT Data View”

Visually you won’t see a huge change, but you now have access to the “Common Data View Tasks” menu which is what we need.

Create a Parameter for the Data View
Next we want to create a new Parameter for the Web Part. This parameter will eventually hold the value of our Date that we will use to filter the list on.
From the “Common Data View Tasks” menu, click on “Parameters”.

Click on “New Parameter”. Give it a name (“DueDate” in this example). Specify the Parameter Source as “Form” (not sure how necessary this is, but it’s what I did when it worked). ‘Form Field’ and ‘Default Value’ are not needed. When you are done you should have a parameter that looks like the following:

Click “OK”. You now have a “DueDate” Parameter created.
Filter the Data View Using the Parameter
Even though our “DueDate” Parameter does not have a value yet and is not connected to a field, we still want to set up our Web Part to be filtered on this Parameter. The Filter is set up as follows:
From the “Common Data View Tasks” Menu select “Filter:”

Click on “Click here to add a new clause”. In this new clause specify the Field Name as “Due Date”, the Comparison should be “Greater Than or Equal”, and the Value should be the parameter we just created “[DueDate]”. When you are finished your filter will look something like:

Click on “OK” and then save your page. We are done with SharePoint Designer.
Drop Date Filter Web Part on Page
It’s time to open up your page in SharePoint. When you do, you will notice you see nothing but an empty list. That’s because our filter is being used with our parameter and it does not have a value for “DueDate” yet. Don’t panic.
Open up the page in Edit mode by clicking on “Site Actions->Edit Page”

in edit mode, click on “Add a Web Part”. Select “Date Filter” from the Filters section and click on “Add”. Again, this is an Enterprise only feature.

Your page now looks something like this:

Go ahead and click “Open the tool pane” or “edit->Modify Shared Web Part” for your Date Filter and give the filter a name of “Due Date Greater Than or Equal To:”

Now click on “Apply”.
Connect Parameter on Data View to Date Filter
We are now ready to connect the Date Filter to the Issues Web Part so that everything works.
From the Issues Web Part click on “edit->Connections->Get Parameters From->Filter: Due Date Greater Than or Equal To:”

Select “DueDate” from the window that pops up and click on “Finish”

That’s it! Now click on “Exit Edit Mode” and let’s see if it works!

Testing it out
Enter a date in the Date Filter or click on the Calendar icon and select a date. Your list should now appear showing all the entries with due dates greater than or equal to the value in the Date Filter

Conclusion
That’s all there is to it. Not too hairy I hope? You can play with this in SPD or play with the XSLT directly and customize this even more, but that’s for another blog post.
Hope you guys learned something! Thanks again for stopping by.
Update:
I was able to get this to work with a date between "Start Date" and "End Date". (Just verified to be sure).
To do this, follow all the steps in this blog and then:
- In SPD, Create another parameter for the list web part for "Date less than or equal to" (I called it "ToDate")
- Add an additional filter to the list web part so that the filter is: "due date" is greater than or equal to "DueDate" and "due date" less than or equal to "ToDate"
- Drop another Date Filter Web Part on the page
- Connect the new date filter to the parameter "ToDate" on your list web part. Using the list web part’s "connections->get parameters from"
Guest Author: Mark Rackley
Mark has been developing software applications for over 15 years filling the roles of Project Manager, Business Analyst, Lead Developer, and Software Architect. He has been involved in projects for such companies as Dell, Motorola, Intel and Agilent Technologies. He has worked in large corporate environments, small software start-ups, and as a consultant. Mark currently works for UNFI where he was introduced to the world of SharePoint and has taken on a lead SharePoint architect role within his organization making key development, administration, and architecture decisions. Mark’s goal is to help ever new architect and developer avoid the frustrations and brick walls he ran into while learning SharePoint.
Blog: http://www.sharepointhillbilly.com
Email: [email protected]
Twitter: http://www.twitter.com/mrackley
- SharePoint Date Filter: Filtering a List by Greater Than or Equal to Date
- Creating a SharePoint List Parent / Child Relationship - Out of the Box
- Passing Multiple Query String Variables Using SPD – Follow Up on Creating Parent / Child List Relationships
- Setting SharePoint Form Fields Using JavaScript
- Tips When Asking For SharePoint Help
- Setting SharePoint Form Fields Using Query String Variables Without Using JavaScript
- Creating a SharePoint List Parent/Child Relationship – VIDEO REMIX
- SharePoint: Populating Drop Down List Field with Data from Different Site
- Building The Right SharePoint Team For Your Organization
Great article. I hope to try this solution soon, but I would imagine you can add a second date parameter where due date is less than or equal to so you can do a date range.
Any luck in using two date part filters- between “Start Date” and “End Date”? I have never been able to get this to work.
Greg,
I was able to get this to work with a date between “Start Date” and “End Date”. (just verified to be sure).
To do this, follow all the steps in this blog and then:
1) In SPD, Create another parameter for the list web part for “Date less than or equal to” (I called it “ToDate”)
2) Add an additional filter to the list web part so that the filter is: “due date” is greater than or equal to “DueDate” and “due date” less than or equal to “ToDate”
3) Drop another Date Filter Web Part on the page
4) Connect the new date filter to the parameter “ToDate” on your list web part. Using the list web part’s “connections->get parameters from”
Put dates in both filters and it should work great! Let me know if you have any problems.
thanks,
Mark
Yeah, I could never get this to work with 2 date params. It has been a while since I tried it, so maybe I should try again…
Mark,
Kudos on this post. It is very clearly documented and definitely a great solution to add to the toolbox.
Thanks again for sharing!
Greg
Awesome tutorial! Shameless plug, though: our Filter Web Part (date range filtering blog article linked above in my name) will let you do this to out-of-box list views (and of course data views), no SharePoint Designer, XSL or coding required… but if third-party tools are not an option, good to know there are other ways to do this (if you have MOSS Enterprise, that is.)
Any way to display items added/update this week as opposed to in past 7 days . Mon-Friday items only
Great instructions. I played further with this and used it to filter multiple text fields as well – using OR in the filter setup to give the filter a wider scope. Only one issue – how do you clear the previous filter results?
Sounds great. I have a calendar which I want to stop users from duplicating meetings at the same time. I thought by testing a date against the start and end dates of existing entries in the calendar, I could stop them saving the entry. I have no idea how to do this. any suggestions
thanks
The above works well for a list – Thank You.
What I can’t seem to do is make it work for a linked source, i.e. two lists joined as a single data source. Effectively I have a list with information that is to be date filtered and has a Contact Id that is used to link to Contact information – simple relational database stuff but implemented in SharePoint.
Can date filtering be done on linked source list?
Hi, I tried the above example. Problem i am facing is when i give “less than or equal” or “greater than equal” and try to filter it gets me results if the exact date selected on the filter, i.e. “less than or equal” or “greater than equal” is not working.
Any ideas?
Rgds,
SSP
An Update.
Regarding my comment oin Jan 21st, I managed to get date filtering working on linked lists. The issue was that SPD was adding in the wrong date comparison details because the format of the dtae text was different from that received from the date filter web part compared to the format being provided from the linked list. Updated the XSL and it all works fine.
I am trying to implement your article as it is
But in SharepointDesigner – Filter Criteria – I added my date parameter, but in condition there is “Greater Than or Equal”.
Please let me know Am I missing anything.