I had a scenario where I needed to filter a SharePoint 2010 discussion list to only show discussions that had been updated within the last 60 days.  My Discussion list is inserted on a page using a DataViewWebPart (DVWP).  So, to filter the discussion list as required, select the DVWP, and then create a filter, like so:

 

Next we need to tweak the code of the filter so that it will be "Greater Than Or Equal to Today, minus 60."

In SharePoint Designer Code view, locate the following bit of code that resides towards the end of the DVWP:

...
selectcommand="<View><Query><OrderBy><FieldRef Name="DiscussionLastUpdated"
Ascending="TRUE"/></OrderBy><Where><Leq><FieldRef Name="
DiscussionLastUpdated"/><Value Type="
DateTime"><Today/></Value></Leq></Where></Query></View>"
...

Before we tweak this code, we can safely convert it as follows:

...
selectcommand="<View><Query>
<OrderBy><FieldRef Name='DiscussionLastUpdated' Ascending='TRUE'/></OrderBy>
<Where><Leq><FieldRef Name='DiscussionLastUpdated'/><Value Type='DateTime'><Today /></Value>
</Leq></Where></Query></View>" 
...

And finally, we simply change that code to the following to include OffsetDays (scroll to the right and look at the Today tag):

...
selectcommand="<View><Query>
<OrderBy><FieldRef Name='DiscussionLastUpdated' Ascending='TRUE'/></OrderBy>
<Where><Geq><FieldRef Name='DiscussionLastUpdated'/><Value Type='DateTime'><Today OffsetDays='-60'/></Value>
</Geq></Where></Query></View>" 
...

The list should now be filtered to only show discussions that have been updated within the past 60 days.  If you re-check the Filter settings for the list, it should look like so:


 

 

Reference blogs.msdn.com