Hi all,
I’ve got a bit of an issue understanding date_bin, as its not returning what I think it should.
I’ve got a data set that is 1 minute apart for each row and I’m doing a specific operation of dealing with one day at a time
SELECT
date_bin(cast(‘1 DAY’ as interval), basetable.ts, 0) AS buckettsFROM safe_1526595589 AS basetable
WHERE basetable.id = ‘801f125aa65d0001’
AND basetable.roundts BETWEEN CAST(‘1662908400000’ AS TIMESTAMP WITH TIME ZONE) AND CAST(‘1663426800000’ AS TIMESTAMP WITH TIME ZONE )
group BY 1
order by 1;
The date range is from
Sunday, September 11, 2022 3:00:00 PM
to
Saturday, September 17, 2022 3:00:00 PM
So I’m expecting 7 rows , a day apart , with timestamps with 3pm :-
2022-09-11T03:00:00.000Z
2022-09-12T03:00:00.000Z
…
2022-09-17T03:00:00.000Z
but I’m getting
2022-09-11T00:00:00.000Z
2022-09-12T00:00:00.000Z
…
2022-09-17T00:00:00.000Z
Is date_bin the wrong function ? should I use a window function ?
Many thanks in advance
David.