How to generate a date range in kdb excluding weekend days?
Asked Answered
I

2

5

This code produces a sequence of dates:

firstdate: 2008.06.01
lastdate: 2008.08.31
daterange: firstdate + til (lastdate - firstdate) + 1

Is it possible to generate the same range excluding weekend dates (Sat/Sun)?

Infante answered 20/4, 2013 at 1:41 Comment(0)
B
5
q)daterange where not (daterange mod 7) in 0 1 
2008.06.02 2008.06.03 2008.06.04 2008.06.05 2008.06.06 2008.06.09 2008.06.10 ..
q)
Besprent answered 20/4, 2013 at 3:3 Comment(2)
I tried to add this to a q script and get an error: "date_range: arg_begin_date + til (arg_end_date - arg_begin_date) + 1". The same line typed at the q console works...Infante
Sorted out: arg_begin_date type in my script was 10h, rather than -14h as on the console.Infante
D
4

easier would be to do daterange where 1<daterange mod 7

Daciadacie answered 20/4, 2013 at 17:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.