How to group todos by week of year?

So far I have this query that shows me TODOs between today and the next 7 days:

#+BEGIN_QUERY
{:title "NEXT WEEK"
:query [:find (pull ?block [*])
:in $ ?start ?end
:where
[?block :block/marker ?marker]
(or
[?block :block/scheduled ?d]
[?block :block/deadline ?d])
[(>= ?d ?start)]
[(<   ?d ?end)]
[(contains? #{"NOW" "LATER" "TODO" "DOING" "WAITING"} ?marker)]]
:inputs [:today :7d-after]
#+END_QUERY

But I want to see TODOs starting NEXT SUNDAY for the subsequent 7 days (i.e. week 3 of 2022).

I had a look at the resolve-input function in logseq/query_react.cljs at fef5bbf0688f8fe28ec21255fb135951395e0ec7 · logseq/logseq · GitHub that handles inputs.

Would it be possible to use Clojurescript time libraries directly in the query? Having access to these libraries would make it easy to calculate the start/end of next week.

I tried the following:

(or
[?block :block/scheduled ?d]
[?block :block/deadline ?d])
[(>= ?d (date->int (t/today)))]
[(<   ?d ?end)]

But it does not work.

How can I approach this? Any ideas welcome

I come across the same issue, can we find any way to query tasks by the end of this week or month?

1 Like