More in this section
Forums / Developing with Sitefinity / Filter News in past 1 year

Filter News in past 1 year

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
3 posts, 0 answered
  1. S R
    S R avatar
    6 posts
    22 Sep 2009
    16 Nov 2010
    Link to this post
    Can i set the FilterExpression property of the NewsView to display all news which are published in the past 1 year?
    i.e in the past 365 days or so ?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    16 Nov 2010
    Link to this post
    Hello S R,

    Using the public property you can hardcode the value of the Publication_Date.

    "Publication_Date >= \"11/16/2009 11:59:11 PM\" AND Expiration_Date > \"11/16/2010 11:59:59 PM\""

    If you want to have a dynamic value that updates with each day you have to work programmatically - override CreateChildControls method where you add the following filter before calling the base

    ContentFilterBuilder filterBuilder = new ContentFilterBuilder(this);
    filterBuilder.AddFilter(new ContentFilterStatement("Publication_Date",        DateTime.Now.AddDays(-365).ToShortDateString();, ContentFilter.Condition.Equal));

    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Rory
    Rory avatar
    44 posts
    22 Mar 2012
    25 Apr 2012
    Link to this post
    how would this be done on version 5?  i cant find ContentFilterBuilder.
Register for webinar
3 posts, 0 answered