Skip to content
aa1024 edited this page Jun 19, 2018 · 7 revisions

Welcome to the datetimeQ wiki!

dtf

Datetime Formatter

format

Format the date as per the given date format

param f: Date formatter e.g. "dd-mm-yyyy"
param dt: Date to be formatted
returns: Formatted date
q)format[fmt:"d/m/yyyy"; dt:2018.06.08]
q)format["d mmmm, dddd ,yyyy"; 2018.06.18]
q)format[f:"yy-mm-dd hh:uu:ss.000"; 2018.06.08T01:02:03.456]
q)do[1000;format[fmt:"yy-mm-dd hh:uu:ss.000 AM/PM"; dt:2018.06.08T21:02:03.456]]

m

Returns Months as 1-12

param x: Date to be formatted
returns: PMnth
q)m[2018.06.08]

mm

Returns Months as 1-12

param x: Date to be formatted
returns: month
q)mm[2018.06.08]

mmm

Months as Jan-Dec

param x: Date to be formatted
returns: month
q)mmm[2018.06.08]

mmmm

Months as January-December

param x: Date to be formatted
returns: month
q)mmmm[2018.06.08]

mmmmm

Months as the first letter of the month

param x: Date to be formatted
returns: month
q)mmmmm[2018.06.08]

d

Days as 1-31

param x: Date to be formatted
returns: Date
q)d[2018.06.08]

dd

Days as 01-31

param x: Date to be formatted
returns: Date
q)dd[2018.06.08]

ddddd

To get Days as Sunday-Saturday

param x: Date to be formatted
returns: Day of the week
q)system"W 4"; dddd[2018.06.08]; system"W 2"
q)system"W 0"; dddd[2018.06.08]; system"W 2"

ddddd

To get Days as Sun-Sat

param x: Date to be formatted
returns: Day of the week
q)system"W 4"; ddd[2018.06.08]; system"W 2"
q)system"W 0"; ddd[2018.06.08]; system"W 2"

m

To get Years as 1900-2099

param x: Date to be formatted
returns: year
q)yyyy[2018.06.08]

m

To get Years as 00-99

param x: Date to be formatted
returns: year
q)yy[2018.06.08]

h

To get Hours as 0-23

param x: Date to be formatted
returns: Hours
q)h 01:05:21

hh

To get Hours as 00-23

param x: Date to be formatted
returns: Hours
q)hh 01:05:21

h1

To get Hours as 1-12

param x: Date to be formatted
returns: Hours
q)h1 01:05:21
q)h1 21:05:21

hh1

To get Hours as 01-12

param x: Date to be formatted
returns: Hours
q)hh1 01:05:21
q)hh1 21:05:21

u

To get Minutes as 0-59

param x: Date to be formatted
returns: Minutes
q)u x:21:05:21.123

uu

To get Minutes as 00-59

param x: Date to be formatted
returns: Minutes
q)uu 01:05:21

s

To get Seconds as 0-59

param x: Date to be formatted
returns: seconds
q)s x:01:05:21

ss1

To get Seconds as 00-59

param x: Date to be formatted
returns: seconds
q)ss1 01:05:21

ampm0

To get Time as 4 AM

param x: Date to be formatted
returns: AM/PM
q)ampm0[21:05:21]

ap0

To get Time as 4 A

param x: Date to be formatted
returns: A/P
q)ap0[21:05:21]

ampm

To get Time as 4 am

param x: Date to be formatted
returns: am/pm
q)ampm[21:05:21]

ap

To get Time as 4 a (a/p)

param x: Date to be formatted
returns: a/p
q)ap[21:05:21]

ms3

To get 3 digits millisecond precision

param x: Date to be formatted
returns: milliseconds
q)ms3[x:21:05:21.123]

ms2

To get 2 digits millisecond precision

param x: Date to be formatted
returns: milliseconds
q)ms2[x:21:05:21.123]

ms1

To get 1 digit millisecond precision

param x: Date to be formatted
returns: millisecond
q)ms1[x:21:05:21.123]

Clone this wiki locally