Search code examples
jquerydatekdbq-lang

How to format a Date in Q language (KDB) to MM/DD


I'm a beginner to KDB/Q Langage, and I'm looking to find a way to convert a date object (or its string representation) to the format MM/DD. For example, I have 2016-09-23 and I would like to format it to 09/23.

There is another thread relating to this subject, but I am not sure how helpful it'd be : How to produce a formatted date string in Q/KDB?

In Q Language, is there any function similar to the ones like convert(varchar, getdate(), 112) in SQL?


Solution

  • If your strings are in a standard format (i.e YYYY-MM-DD), it will be quicker to use indexing @ depth.

    q)list:("2016-09-23";"2016-10-23") 
    q)5_'.[list;(::;4 7);:;"/"]
    "09/23" 
    "10/23"