How can I exclude future journal pages from Datalog queries?

Hello, sometimes I create future journal pages and put to-dos on them. Can someone show me a query that will get all TODO tasks excluding those on a journal page with a future date? I can’t work it out. Thank you for your generosity.

So I’ll be pulling from this topic for the answer:

A few queries down in the first post we have “Open unplanned tasks from journal pages”.
There we have something for journal pages. It also happens to have today in it.
Only it has scheduled, we don’t need that.

So we modify the query a little bit to get (I’ve also updated it for how I write queries today :P):

{:title [:h3 "☑ Tasks"]
 :inputs [:today]
 :query [:find (pull ?b [*])
 :in $ ?day
  [?p :block/journal-day ?d]  ; ?p has the attribute journal-day with value ?d (you don't need the :block/journal? attribute if you also use this one)
  [(<= ?d ?day)] ; the value of ?d needs to be before or on ?day (today that is)
  [?b :block/page ?p]  ; ?b has the attribute :block/page with value ?p, ?p has been define with the identifier of a journal page above.
  [?b :block/marker "TODO"] ; ?b is a task marked as TODO.
 :breadcrumb-show? false
 :result-transform (fn [result] (sort-by (fn [r] (get-in r [:block/page :block/journal-day])) result))  ; Sort by the journal date

Thank you Siferiax I was able to go from there. :+1::heart:

1 Like