Date time to date

Hi,

I am trying to create a query entity. I have the following fields in the database: trans_date(datetime variable), trans_id(number),trans_amount(number). I am trying to write a query to return the sum of all transactions today. the only issue i am facing is to find the transactions today as trans_date is a datetime variable. I cannot filter this field using 'today' because type mismatch. I can only filter it with now() which results in 0 results as expected.  I also tried field: todate("trans_date") which resulted in error.

Also, when I try to include trans_date in aggregation for grouping it only groups the transactions that happened at the exact same time as it is a date time variable.

 

Any help is appreciated

Thanks,

Yeswanth.

  Discussion posts and replies are publicly visible

Parents
  • Hi Yeswanth,
    This may not be very good approach, but can you try

    a!queryFilter(
    field: "trans_date",
    operator: "<",
    value: todatetime(today() + 1)
    ),
    a!queryFilter(
    field: "trans_date",
    operator: ">",
    value: todatetime(today() - 1)
    )

    But remember, output of todatetime() will be based on user timezone.
    Or you can try to make date time something like datetime(year(today()),month(today()),day(today()),00,00,00)
Reply
  • Hi Yeswanth,
    This may not be very good approach, but can you try

    a!queryFilter(
    field: "trans_date",
    operator: "<",
    value: todatetime(today() + 1)
    ),
    a!queryFilter(
    field: "trans_date",
    operator: ">",
    value: todatetime(today() - 1)
    )

    But remember, output of todatetime() will be based on user timezone.
    Or you can try to make date time something like datetime(year(today()),month(today()),day(today()),00,00,00)
Children