Hello Is it possible to bucket per week, but start...
# troubleshooting
j
Hello Is it possible to bucket per week, but starting on an arbitrary week day ?
x
You can do the offset first, then bucketing, then reverse the offset?
j
I'm can't seen to find how to do offsetting ?
x
something like
date_trunc(ts-3d, 'week') + 3d
πŸ‘Œ 1
😯 1
j
From my testing, it seems this only works with floats (epoch) and the
d
is ignored, meaning that we are subtracting the multiplier (say
3
in whatever unit the epoch is) For example:
Copy code
SELECT
    dateString AS original_datestring, 
    fromDateTime(dateString, 'yyyy-MM-dd') AS original_epoch, 
    toDateTime(fromDateTime(dateString, 'yyyy-MM-dd') -  '10d', 'yyyy-MM-dd') AS offset_datestring, 
    fromDateTime(dateString, 'yyyy-MM-dd') -  '10d' AS offset_epoch 
FROM table
Results in:
image.png
Not a big deal, but I'm trying to understand how those
d
work πŸ˜„
x
yeah, it’s 3 * 86400 * 1000 πŸ˜›
j
Ah ! πŸ˜„ Thanks @Xiang Fu