Copied to clipboard

Flag this post as spam?

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


  • Proxicode 128 posts 324 karma points
    Jul 11, 2015 @ 19:52
    Proxicode
    0

    Parse date from dateTime picker

    Hello all,

    I am trying to to use the value from a date time picker to do a comparison and it seems to be being ignored. The code runs fine, no errors, and the OrderBy is working correctly, but the .Where is not applied to the list. I'm thinking that I must be missing something obvious. Here is my code

    IEnumerable<dynamic> allEvents = CurrentPage.ChildrenAsList;
    var activeEvents = allEvents.OrderBy(ev => ev.eventDate).Where(e => DateTime.Parse(e.eventDate) >= DateTime.Now);
    

    I also tried

    IEnumerable<dynamic> allEvents = CurrentPage.ChildrenAsList;
    var activeEvents = allEvents.OrderBy(ev => ev.eventDate).Where(e => e.eventDate >= DateTime.Now);
    

    and

    IEnumerable<dynamic> allEvents = CurrentPage.ChildrenAsList;
    var activeEvents = allEvents.OrderBy(ev => ev.eventDate).Where(e => Convert.ToDateTime(e.eventDate) >= DateTime.Now);
    

    But still, events with last weeks date are being returned in my list.

    Any ideas?

    Thanks -Roger

  • Proxicode 128 posts 324 karma points
    Jul 11, 2015 @ 21:16
    Proxicode
    0

    Disregard - I found this to be the winning combination :-)

    var allEvents = ((IEnumerable<dynamic>)CurrentPage.ChildrenAsList).Where(e => e.eventDate >= DateTime.Now).OrderBy(e => e.EventDate);
    
Please Sign in or register to post replies

Write your reply to:

Draft