首页 > 解决方案 > 如何在 KDB 中按月选择?

问题描述

我有一张表格

t                             r             v    
-------------------------------------------------
2016.01.04D09:51:00.000000000 -0.01507338   576  
2016.01.04D09:52:00.000000000 -0.001831502  200  
2016.01.04D11:37:00.000000000 -0.001100514  583  
2016.01.04D12:04:00.000000000 -0.001653045  1000 

我想获得 2020 年 10 月的值。

我试着做一个查询:

select from x where t.month = 2020.10

但这没有用。我想我可能需要转换日期类型?我究竟做错了什么?

标签: kdb

解决方案


尾随m允许解释器知道原子是月份类型而不是浮点类型。

q)type 2020.10
-9h
q)type 2020.10m
-13h
q)select from x where t.month=2020.10
t
-
q)select from x where t.month=2020.10m
t
-----------------------------
2020.10.20D20:20:00.000000000

推荐阅读