Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 939 posts 2574 karma points
    Mar 14, 2019 @ 09:11
    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 1284 posts 4038 karma points MVP 8x c-trib
    Mar 14, 2019 @ 12:34
    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 939 posts 2574 karma points
    Mar 22, 2019 @ 06:59
    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