2022.01.11 12:14 PM
Im using .z.n in my tick.q and wondering if theres a way to not show 0D infront of the timespan.
Currently it shows:
0D20:06:22.271520000
I want this
20:06:22.271520000
2022.01.13 03:10 AM
If you want to keep the nanosecond granularity, you will have to keep the value as a timespan, and the prefacing 0D.
You can see some more examples of time conversions here: https://code.kx.com/q/kb/temporal-data/#comparing-temporals
Hope that helps clarify, and thanks for your questions!
Laura
2022.01.11 01:27 PM
You can resolve this by casting the type from timespan to time.
"t"$.z.n
However, the result will be in milliseconds, not nanoseconds.
2022.01.11 01:31 PM
Yes but is it possible to keep as a timespan?
2022.01.13 03:10 AM
If you want to keep the nanosecond granularity, you will have to keep the value as a timespan, and the prefacing 0D.
You can see some more examples of time conversions here: https://code.kx.com/q/kb/temporal-data/#comparing-temporals
Hope that helps clarify, and thanks for your questions!
Laura
2022.01.13 06:53 AM
The day part is an integral portion of the datatype and will display by default.
In a UI/display time it can be dropped if required:
q)2_string .z.n /Atom
"14:41:40.125906000"
q)2_/:string 2#.z.n /List
"14:42:00.701751000"
"14:42:00.701751000"
q)update 2_/:string time from ([] time:2#.z.n) /Column in table
time
--------------------
"14:42:38.625329000"
"14:42:38.625329000"
// All columns of timespan type in a table
q)dropDays:{c:where -16h=type each first x;$[count c;![x;();0b;c!{((/:;_);2;($:;x))}each c];x]}
q)dropDays ([] time:2#.z.n;b:1.1 1.2)
time b
------------------------
"14:47:37.376270000" 1.1
"14:47:37.376270000" 1.2
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.