I want to find only scheduled and deadlined tasks which are overdue (Deadline day less than today or schedule day less than today).
#+BEGIN_QUERY
{:title "Overdue"
:query [:find (pull ?block [*])
:in $ ?start ?end
:where
(or
[?block :block/scheduled ?d]
[?block :block/deadline ?d]
)
[(> ?d ?start)]
[(<= ?d ?end)]
]
:inputs [:-500d :-1d]
:collapsed? false}
#+END_QUERY
The query above finds not tasks too, i need only tasks.
I tried add this line to where
block (task ?block #{"LATER" "TODO" })
, but then query can’t find anything. I need your help
#+BEGIN_QUERY
{:title "Overdue"
:query [:find (pull ?block [*])
:in $ ?end
:where
[?block :block/marker ?marker]
[(contains? #{"DONE" "CANCELED"} ?marker)]
[?block :block/marker ?marker]
(or
[?block :block/scheduled ?d]
[?block :block/deadline ?d]
)
[(<= ?d ?end)]
]
:inputs [:-1d]
:collapsed? false}
#+END_QUERY
This one works, but if i change DONE and CANCELED to LATER and TODO it doesn’t work. Why?!
I was stupid, i just hadn’t had any overdue tasks. So, you can use my query
#+BEGIN_QUERY
{:title "Overdue"
:query [:find (pull ?block [*])
:in $ ?end
:where
[?block :block/marker ?marker]
[(contains? #{"LATER" "TODO"} ?marker)]
[?block :block/marker ?marker]
(or
[?block :block/scheduled ?d]
[?block :block/deadline ?d]
)
[(<= ?d ?end)]
]
:inputs [:-1d]
:collapsed? false}
#+END_QUERY
4 Likes
nice solve!
I can’t remember the times I was confused not getting output and the problem was the data not the query 
2 Likes
I would like to pay homage to the miracle of someone not having any overdue tasks. HUZZAH!!!