7.2 Interval-based search

 

SQL

SELECT *
FROM Orders
WHERE OrderDate>='2021-12-29' and OrderDate<='2021-12-31'

SPL

For numeric and date type fields, interval-based searches are often needed. And sorting index is the only suitable one for those fields involving interval-based search.

A
1 >st=date(“2021-12-29”), et=date(“2021-12-31”), start=days@o(st), end=days@o(et)
2 =file(“Orders.ctx”).open()
3 =A2.index(ids;OrderDate)
4 =A2.icursor(;OrderDate>=start && OrderDate<=end).fetch()