More in this section

Forums / Developing with Sitefinity / Using FilterExpressions with dates

Using FilterExpressions with dates

5 posts, 0 answered
  1. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    02 Oct 2007
    Link to this post
    Hi,

    I have seen posts on the filter expression field of the news list but what I am trying to do is get rid the news items older than 1 month for a newslist titled "Current News" and on another news list list all the news items > 1 month old.


    Has anyone come across this?

    Seth



  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    02 Oct 2007
    Link to this post
    Hello Seth,

    As you have mentioned, you can use the  FilterExpression property of the NewsList control.Here is a thread that might guide you to achieve the required functionality. For example FilterExpression for the first news list should be: Publication_Date > 09/02/2007

    Don't hesitate to contact us if you need any further assistance.

    Kind regards,
    Author nickname
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    04 Oct 2007
    Link to this post
    Hi,

    Thanks for the reply... not exactly what I was after. If I manually type in the Publication_Date > 09/02/2007 then the following day the filter will be wrong as I only want to see news items published in the last month... sort of like Publication_Date > datetime.now - 1 month.

    Thanks 
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    04 Oct 2007
    Link to this post
    Hello Seth,

    Maybe I wasn't clear enough in my previous post where I was just showing what the expression should look like. More  information can be found in the thread I recommended. So let me make a short summary of how you can generate the FilterExpression dynamically:

    1. Create a User Control that wraps the NewsList control.
    2. Generate the filter expression
    programmatically and set the value to FilterExpression property in the Page_Load  method.

    In the attachment you can find a very simple example demonstrating the implementation of the required functionality.

    Best wishes,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. UI Crew
    UI Crew avatar
    151 posts
    Registered:
    27 Sep 2012
    04 Oct 2007
    Link to this post
    Hi Pepi,

    Sorry i did read that thread but didn't realise I would have to create a user control.

    Thanks, I'll have a look at making a usercontrol.

    Cheers,

    Seth
Register for webinar
5 posts, 0 answered