Advance Query - All todos in current week

Hi experts

I’m a newbie in advance query. I would like to see all todos in the current week. Here is my query which is not working. Any suggestions? Thank you in advance.

{:title “Todos this week”
:query [:find (pull ?todo [*])
:in $ ?start ?end
[?todo :todo/todo ?d]
[?todo :todo/later ?d])
[(> ?d ?start)]
[(< ?d ?next)]]
:inputs [:monday :friday]
:collapsed? false}

You mostly got it. This will work:

{:title "Todos this week"
 :query [:find (pull ?h [*])
:in $ ?start ?end
[?h :block/marker ?marker]
[(contains? #{"TODO" "DOING" "NOW" "LATER"} ?marker)]
[?h :block/scheduled ?day]
[(> ?day ?start)]
[(< ?day ?end)]
:inputs [:7d-before :today]
:collapsed? false}

It’s not working.
Did I miss something?

Do you have TODOs in the last week?

If you’re wanting TODOs in the next week, replace with:
:inputs [:today :7d-after]

Tested on my notes, both work.

Thank you noted. Just found a query fits my needs. I should have read it before asking questions.
It’s no. 9 in

{:title “:green_circle: ACTIVE”
:query [:find (pull ?h [*])
:in $ ?start ?today
[?h :block/marker ?marker]
[?h :block/page ?p]
[?p :page/journal? true]
[?p :page/journal-day ?d]
[(>= ?d ?start)]
[(<= ?d ?today)]
[(contains? #{“NOW” “DOING”} ?marker)]]
:inputs [:14d :today]
:result-transform (fn [result]
(sort-by (fn [h]
(get h :block/priority “Z”)) result))
:collapsed? false}

1 Like