如何在Q/KDB中产生格式化的日期字符串? [英] How to produce a formatted date string in Q/KDB?
问题描述
如何从Q日期类型中产生ISO日期字符串"yyyy-MM-dd"?我看着连接各个部分,但什至无法获得日/月,例如d:2015.12.01;d.month
打印2015.12
,即不只是月份.
How can one produce an ISO date string "yyyy-MM-dd" from a Q date type? I looked at concatenating the various parts but am not even able to get the day/month, e.g. d:2015.12.01;d.month
prints 2015.12
, i.e. more than just the month.
推荐答案
q)"-" sv "." vs string[2015.12.01]
"2015-12-01"
字符串中的
vs
向量,以."分隔.以上;
sv
字符串到矢量,在上面用-"连接.
vs
vector from string, splits by "." above;
sv
string to vector, join by "-" above.
请记住,字符串只是一个char数组,因此您可以根据需要使用索引来抓取每个部分.但是上面的方法很有用,因为vs
的结果向量提供了一个3长度的向量,您可以按照自己喜欢的方式进行操作
Remember a string is just a char array, so you can grab each part as you require with indexing. But the above is useful as the resulting vector of vs
gives a 3-length vector that you manipulate any way you like
这篇关于如何在Q/KDB中产生格式化的日期字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!