Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 800 posts 2039 karma points
    1 week ago
    Claushingebjerg
    0

    Error in query builder when using dates

    Just tried the built in query builder to list some pages where the publish date is greater than some date, and it fails out of the box... Whats the right syntax?

    enter image description here

    enter image description here

  • Bjarne Fyrstenborg 1117 posts 3015 karma points MVP 2x c-trib
    1 week ago
    Bjarne Fyrstenborg
    100

    The value you compare the CreateDate with doesn't seem to be in correct format as 3/6/2019 12:00:00 AM or "3/6/2019 12:00:00 AM".

    You need to convert/parse this to a DateTimeobject, e.g.

    .Where(x.CreateDate >= new DateTime(2019, 3, 6, 12, 0, 0));
    

    or

    .Where(x.CreateDate >= DateTime.Parse("yyyy-MM-dd HH:mm:ss"));
    

    where yyyy-MM-dd HH:mm:ss is your date time format.

  • Claushingebjerg 800 posts 2039 karma points
    4 days ago
    Claushingebjerg
    0

    I ended up with

    var now = DateTime.Now;
    var eventtimeclean = item.Value<DateTime>("eventdato");
    if (eventtimeclean > now) { 
     (my stuff)
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft