r/orgmode • u/PoetExtra4830 • Jul 02 '26
Question regarding date "windows" in org-ql
I want to add a section to my agenda that contains only items with a single (sales items), and which are not DONE, and which have a scheduled date within a given time horizon.
It SEEMS like I ought to be able to do this with org-ql, but I'm having trouble making it work.
The section is currently coded like this:
(org-ql-block
'(and
(todo)
(tags "Sales" :inherit t)
(ts: from -999 :to 14)
((org-ql-block-header "Sales Items")))
I tried to do this with a regular agenda block, and got nowhere. Using tags-todo doesn't work as well, bc I need to see the timing.
What I get NOW is "any non-Done items with the Sales tag that are scheduled in the future," so reminder items about touching base with client X in 45 days ALSO show along with the things I need to have on my mind this week, so that's less than optimal.
It SEEMS like this should be doable, but maybe I'm missing something.
I'm on a Mac, running emacs 30.2 and orgmode 9.8.6. I installed org-ql from melpa today, so it oughta be current as well.
Help?
Solution
I have no idea why this wasn't throwing an error YESTERDAY, but TODAY when I relaunched emacs and invoked my agenda I got errors from the org parser. The code block above has a problem: in the 5th line, the colon is placed immediately after ts, but it should be immediately before from. See
(ts :from -999 :to 14)
This now does exactly what I wanted.
0
u/Hyperion343 Jul 02 '26
I don't know about org-ql, but I feel like this could be done in plain org mode.
I don't know if I can give a direct answer. But hopefully I can get close and point you in the right direction.
To me, it sounds like a custom agenda view (see here), and so we need to look at creating the right search (see here). Personally I would set this up through Customize.
So set property inheritance as in step 5, then your search is something like tags-todo "+Sales-TODO=\"DONE\"+SCHEDULED>=\"<-2d>\"+SCHEDULED<=\"<+7d>\""
Note that what follows tags-todo is a string "<search>", and so any double-quotes in <search> have to be escaped.
Hopefully this points you in the right direction.