Copied to clipboard

Flag this post as spam?

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

  • Claushingebjerg 829 posts 2143 karma points
    Mar 14, 2019 @ 09:11

    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 1138 posts 3222 karma points MVP 3x c-trib
    Mar 14, 2019 @ 12:34
    Bjarne Fyrstenborg

    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));


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

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

  • Claushingebjerg 829 posts 2143 karma points
    Mar 22, 2019 @ 06:59

    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: