Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • James Inger 11 posts 102 karma points
    Nov 17, 2018 @ 05:49
    James Inger
    0

    Custom Query - Select all entries after a specific date from DateTime parameter

    Hi All,

    I have created a query to find all events.

    Each event has a date time control

    Can I create a query, when given a certain date will find all dates after(and including) that date and then display them

    To find all events this query works

    var nodes = Model.Content.Site().FirstChild("eventsPage").Children("eventsItem").Where(x => x.IsVisible()).OrderBy("CreateDate desc");
    

    I then just loop through the node.

    I'm sure i need to put in the WHERE clause, but do not know the syntax.

    Also how to order by the date parameter would be awesome as well.

    How can I specify a parameter to search?

  • Marc Goodson 2155 posts 14406 karma points MVP 9x c-trib
    Nov 18, 2018 @ 13:03
    Marc Goodson
    0

    Hi James

    if your special property has an alias 'eventDate' for example then would the following work?

    var cutOffDate = DateTime.Now;
    
    var nodes = Model.Content.Site().FirstChild("eventsPage").Children("eventsItem").Where(x => x.IsVisible() && x.HasProperty("eventDate") && x.HasValue("eventDate") && x.GetPropertyValue<DateTime>("eventDate") > cutOffDate).OrderByDescending(x=>x.GetPropertyValue<DateTime>("eventDate"));
    

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft