Consider the following table:
let fooTable = datatable(ts: long) [
1655139949044,
1655053767530,
];
It has two unix timestamp values in milliseconds, and the dates are:
2022-06-12T17:09:27.53Z
2022-06-13T17:05:49.044Z
I want to COUNT() group by the date rounded by week.
One query uses bin on timestamp field,
let fooTable = datatable(ts: long) [
1655139949044,
1655053767530,
];
let bucket_ts = 1m * 10080;
fooTable | summarize count() by bin(unixtime_milliseconds_todatetime(ts), bucket_ts)
And the second query uses bin on Long value.
let fooTable = datatable(ts: long) [
1655139949044,
1655053767530,
];
let bucket_long = 60000 * 10080;
fooTable | summarize count() by bin(ts, bucket_long) | extend ts=unixtime_milliseconds_todatetime(ts)
I'm trying to understand why they yield different results - I expected results to be the same (for example, former yields 2 rows, and the latter 1 (as I expected)).
It seems like when bin on date types - it groups it by constant time buckets, but on long types it simply floors it to the previous week (based on the relative time).
I want to bin on datetime types, to behave like the Long example. How can I do that still using the datetime type?
I guess the easy answer is to convert the datetime to Long, but this solution seems quite messy to me.