How do I convert from symbol to integer?

Convert to string, then to int by applying the $ (cast) operator while passing an uppercase type character as its left argument:

q)”I” $ string `123
123
q)

Type number also works:

q)type 123
-6h
q)-6h $ string `123
123
q)

See also: string to symbol conversion faq, Datatypes and $


This work is licensed under a Creative Commons License.
The views and opinions expressed herein are those of the authors and do not necessarily reflect those of any other person or legal entity.
Kdb+ is the registered trademark of Kx Systems, Inc.