Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

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