AND TO_TIMESTAMP(tickets.created_at, 'YYYY-MM-DD"T"HH24:MI:SS"Z"')::date >= {{ dateRange1.value.start }}
In this query, TO_TIMESTAMP function is used to convert the created_at string to a timestamp with the specified format. Then, the ::date operator is used to extract the date part from the timestamp.
I did not test the code chunk I sent you and got this answer from ChatGPT. I do believe TO_TIMESTAMP is part of SQL (Postgres engine at least). I could not quicky find it for MySQL engine that's why I'm asking.
Hi @Tommy_Fiacco ! Dealt with what I'm assuming is a similar problem a bit ago. Here's what might work for you:
Goal: filter for all tickets with created_at date that comes after {{dateRange1.value.start}}
Suggestion: and date(tickets.created_at::date) >= {{ dateRange1.value.start }}
My data comes in as captured_at: "2024-01-13T00:00:13.549Z", and using
WHERE date(status.captured_at) <= (CURRENT_DATE) and date(status.captured_at) > (CURRENT_DATE-7)
allows me to filter out a 7 day range from a given date, so should work in your case as well (given that CURRENT_DATE returns 2024-01-18, so i'd assume your dateRange1.value.start is in the same 'YYYY-MM-DD' format).
Have worked a lot with filtering dates & datetimes, so happy to chat more if needed
Also, like @preshetin said, Retool uses AlaSQL, so poking around their docs might be helpful as well