I am looking for special query input to find all my tasks not for next 7 days, i want find tasks for an actual week. From today to Sunday of this week.
I would like to see that too! As it stands I think your best option is a plugin.
(We basically don’t know what day of the week today is)
Alternatively an unreliable query I build for myself.
#+BEGIN_QUERY
{:title [:b "Next Sunday"]
:query [:find (pull ?p [*])
:in $ ?day ?today
:where
[(- ?today ?day) ?diff]
[(mod ?diff 7) ?n]
[(- ?today ?n) ?sunday]
[?p :block/journal-day ?sunday]
]
:inputs [20230604 :today]
}
#+END_QUERY
What it does is it determines what the following Sunday is from today based on an input date that is a Sunday.
Because this is all integer (numbers) work though, it can give odd/no results when going to the next month. It will determine the next Sunday is 20230598 (recent example).
Which returns nothing.
It’s a hack basically.
Check out this feature request as well:
If you don’t mind a (very) long query, you may adapt this one to filter from today up to this week’s Sunday, e.g.:
#+BEGIN_QUERY
{
:title [:b "laterSameWeek"]
:inputs [:today :+6d]
:rules [
[(laterSameWeek ?date-a ?date-b)
[(mod ?date-a 100) ?monthday-a]
[(mod ?date-a 10000) ?mod-a]
[(quot ?mod-a 100) ?month-a]
[(- ?month-a 8) ?month8-a]
[(quot ?month8-a 6) ?month6-a]
[(* ?month6-a 12) ?month12-a]
[(- ?month-a ?month12-a) ?monthnum-a]
[(inc ?monthnum-a) ?monthinc-a]
[(* 13 ?monthinc-a) ?month13-a]
[(quot ?month13-a 5) ?month5-a]
[(quot ?date-a 10000) ?year-a]
[(+ ?year-a ?month6-a) ?year6-a]
[(mod ?year6-a 100) ?yearnum-a]
[(quot ?yearnum-a 4) ?year4-a]
[(quot ?year6-a 100) ?century-a]
[(quot ?century-a 4) ?century4-a]
[(* 5 ?century-a) ?century5-a]
[(+ ?monthday-a ?month5-a ?yearnum-a ?year4-a ?century4-a ?century5-a) ?sum-a]
[(mod ?sum-a 7) ?d-a]
[(mod ?date-b 100) ?monthday-b]
[(mod ?date-b 10000) ?mod-b]
[(quot ?mod-b 100) ?month-b]
[(- ?month-b 8) ?month8-b]
[(quot ?month8-b 6) ?month6-b]
[(* ?month6-b 12) ?month12-b]
[(- ?month-b ?month12-b) ?monthnum-b]
[(inc ?monthnum-b) ?monthinc-b]
[(* 13 ?monthinc-b) ?month13-b]
[(quot ?month13-b 5) ?month5-b]
[(quot ?date-b 10000) ?year-b]
[(+ ?year-b ?month6-b) ?year6-b]
[(mod ?year6-b 100) ?yearnum-b]
[(quot ?yearnum-b 4) ?year4-b]
[(quot ?year6-b 100) ?century-b]
[(quot ?century-b 4) ?century4-b]
[(* 5 ?century-b) ?century5-b]
[(+ ?monthday-b ?month5-b ?yearnum-b ?year4-b ?century4-b ?century5-b) ?sum-b]
[(mod ?sum-b 7) ?d-b]
[(- ?d-a 4) ?d4-a]
[(- ?d-b 4) ?d4-b]
[(quot ?d4-a 3) ?d3-a]
[(quot ?d4-b 3) ?d3-b]
[(* ?d3-a 7) ?d7-a]
[(* ?d3-b 7) ?d7-b]
[(- ?d-a ?d7-a) ?dnum-a]
[(- ?d-b ?d7-b) ?dnum-b]
[(>= ?dnum-b ?dnum-a)]
]
]
:query [
:find (pull ?b [*])
:in $ ?today ?max %
:where
(or [?b :block/scheduled ?d] [?b :block/deadline ?d])
[(>= ?d ?today)]
[(<= ?d ?max)]
(laterSameWeek ?today ?d)
]
}
#+END_QUERY
3 Likes