How to show all SCHEDULED with filters

I found this great query (thanks to who ever made it!)

#+BEGIN_QUERY
{:title " Scheduled dates found in any block"
:query [:find (pull ?b [*])
:where
[?b :block/scheduled ?d]
[(not= ?d nil)]]
:collapsed? false}
:result-transform (fn [result]
                     (sort-by (fn [b]
                                (get b :block/scheduled))
                                (fn [a b] (> a b))
                                result))
#+END_QUERY

This shows ALL SCHEDULED (while other queries I found are all both “TODO + SCHEDULED”)

From here, I want to modify it to show only queries from today to the next 7 days.

Also, is there a way to filter and show all SCHEDULED from the PAGES that are tagged with certain word. For example, I want to show all SCHEDULED from all pages tagged with Research. Note that the tags can be in either page properties or anywhere in that page.

Need some help here. Thanks!

1 Like

For the date filter, I tried the following. But it does not work.

#+BEGIN_QUERY
{:title " Scheduled dates found within next 10 days"
:query [
:find (pull ?b [*])
:in $ ?start ?next
:where
[?b :block/scheduled ?d]
(between ?b ?start ?next)
[(not= ?d nil)]
]
:inputs [:today :10d-after]
:collapsed? false
}
:result-transform (fn [result]
                     (sort-by (fn [b]
                                (get b :block/scheduled))
                                (fn [a b] (> a b))
                                result))
#+END_QUERY

Try something like this:

#+BEGIN_QUERY
{:title "🟡 NEXT (scheduled)"
:query [:find (pull ?h [*])
:in $ ?from ?until
:where
[task ?h #{"LATER" "TODO"}]
(or [?h :block/deadline ?d]
[?h :block/scheduled ?d]
)
[?h :block/scheduled ?s]
[(>= ?d ?from)]
[(<= ?d ?until)]
[(<= ?s ?until)]
]
:inputs [:360d :today]
:result-transform (fn [result]
 (sort-by (juxt
           (fn [h] (get h :block/deadline 99999999))
           (fn [h] (get h :block/priority "Z"))
           (fn [h] (get h :block/scheduled 99999999))
           )
          result))
:breadcrumb-show? false
:collapsed? false}
#+END_QUERY
1 Like