Try Now
More in this section

Forums / Developing with Sitefinity / Filter News in past 1 year

Filter News in past 1 year

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
    19 Oct 2016
    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