I have a DATE
column that I want to round to the next-lower 10 minute interval in a query (see example below).
I managed to do it by truncating the seconds
I think to solve this there's a much easier and faster way to round to a next lower 10 seconds, 1 Minute, 10 Minute etc. interval. Try to manipulate your timestamp as a string using SUBSTR() like this:
SELECT
SUBSTR(datetime(d),1,18)||'0' AS Slot10sec,
SUBSTR(datetime(d),1,17)||'00' AS Slot1min,
SUBSTR(datetime(d),1,15)||'0:00' AS Slot10min,
SUBSTR(datetime(d),1,14)||'00:00' AS Slot1h,
MY_VALUE
FROM MY_TABLE;