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)?

Robert Kubrick
  • 8,413
  • 13
  • 59
  • 91

2 Answers2

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)
user1895961
  • 1,176
  • 9
  • 22
  • 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... – Robert Kubrick Apr 22 '13 at 16:44
  • Sorted out: arg_begin_date type in my script was 10h, rather than -14h as on the console. – Robert Kubrick Apr 22 '13 at 16:50
4

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

Sergey V
  • 231
  • 1
  • 3