datetimerowskdbq

Select time windows across multiple days from datetime column


Given a kdb table with a column of datetime type values, is there a simple q query to select all the rows which have their time within a particular window but on any date?


Solution

  • Something like this?

    q)t:([]10?.z.z)
    q)t
    z
    -----------------------
    2003.06.26T07:32:45.704
    2021.09.30T06:05:45.588
    2015.08.27T14:41:02.619
    2020.12.25T13:06:28.033
    2017.05.30T05:15:00.394
    2009.02.09T22:27:48.524
    2013.07.30T00:10:19.679
    2011.01.22T19:25:44.318
    2009.01.31T04:21:12.165
    2009.12.29T19:41:11.965
    q)select from t where z within 06:41 15:32
    z
    -----------------------
    2003.06.26T07:32:45.704
    2015.08.27T14:41:02.619
    2020.12.25T13:06:28.033