cancel
Showing results for 
Search instead for 
Did you mean: 

0D infront of timespan

ekallivrousis
New Contributor III

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

 

1 ACCEPTED SOLUTION

Laura
Community Manager Community Manager
Community Manager

Hi @ekallivrousis 

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

View solution in original post

4 REPLIES 4

M_Klontzakis
New Contributor

You can resolve this by casting the type from timespan to time.

"t"$.z.n

However, the result will be in milliseconds, not nanoseconds.

Yes but is it possible to keep as a timespan? 

Laura
Community Manager Community Manager
Community Manager

Hi @ekallivrousis 

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

rocuinneagain
Contributor
Contributor

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