Query beetwen two dates

Certified Senior Developer

Hi,
I kindly ask you for an opinion on a problem that I have been dragging along for some time.
I have a query in which I need to extract data between two dates: startDate and endDate.
The data on the db and CDT are in date and time format.
The range extremes are entered from the user interface in Date format, the same are the query rule inputs.

a!queryFilter(
   field: "timestamp",
   operator: "between",
   value: {
       todatetime(ri!startDate),todatetime(ri!endDate)
   }
),

But when I do, for example, todatetime (12/21/2020), I get 12/21/2020 1:00 AM GMT + 01: 00 (in my local time zone).

So I can't actually take dates from the beginning of startDate=00:00 AM to the end of endDate= 11:59 PM.

I am trying this solution:

a!queryFilter(
    field: "timestamp",
    operator: "between",
    value: {
      todatetime(concat(tostring(ri!startDate), " 00:00 AM")),
      todatetime(concat(tostring(ri!endDate), " 11:59 PM"))
    }
), 

It's that right? Are there any other solutions?

Regards, and thank you very much

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Lead Developer
    in reply to Gabriele Minardi

    I don't believe that's likely given what I suggested above - quite literally what it will query is ("anything from the beginning of startDate") until ("end of the day on endDate").  The only possible extra adjustment that would be needed is ensuring your values are playing properly with GMT, and that's pretty easy to test by adding some test entries to the DB with times very near midnight (some just before and some just after) to make sure they come up in the expected query.

Children
No Data