Round down

x xbar y    xbar[x;y]

Where

returns y rounded down to the nearest multiple of x.

q)3 xbar til 16
0 0 0 3 3 3 6 6 6 9 9 9 12 12 12 15
q)2.5 xbar til 16
0 0 0 2.5 2.5 2.5 5 5 5 7.5 7.5 7.5 10 10 10 12.5
q)5 xbar 11:00 + 0 2 3 5 7 11 13
11:00 11:00 11:00 11:05 11:05 11:10 11:10

Interval bars are useful in aggregation queries. To get last price and total size in 10-minute bars:

q)select last price, sum size by 10 xbar time.minute from trade where sym=`IBM
minute| price size
------| -----------
09:30 | 55.32 90094
09:40 | 54.99 48726
09:50 | 54.93 36511
10:00 | 55.23 35768
...

Group symbols by closing price:

q)select sym by 5 xbar close from daily where date=last date
close| sym
-----| ----------------------
25   | `sym$`AIG`DOW`GOOG`PEP,...
30   | `sym$,`AAPL,...
45   | `sym$`HPQ`ORCL,...
...
You can use bin to group at irregular intervals.


q)x:`s#10:00+00:00 00:08 00:13 00:27 00:30 00:36 00:39 00:50
q)select count i by x x bin time.minute from ([]time:`s#10:00:00+asc 100?3600)
minute| x
------| --
10:00 | 8
10:08 | 13
10:13 | 24
10:27 | 4
10:30 | 9
10:36 | 3
10:39 | 19
10:50 | 20

A month is (internally) the count of months since 2000, so you can use 3 xbar to calculate quarters.

q)`date$3 xbar `month$2019.11.19       / beginning of a quarter
2019.10.01
q)`date$3+3 xbar `month$2019.11.19     / beginning of next quarter
2020.01.01
q)-1+`date$3+3 xbar `month$2019.11.19  / end of that quarter
2019.12.31