Query undated TODOs

Is there a way to query or advanced query TODO with no date marker? (Undated TODOs)

Thank you in advance.


Here you are (quick & dirty):

			{:title "⚠️NO DATE"
			  :query [:find (pull ?b [*])
					  :in $ ?start 
						[?b :block/marker ?marker] [(= "TODO" ?marker)]	  
						(not [?b :block/scheduled])
						(not [?b :block/deadline]) 
			  :inputs [:today]
			:result-transform (fn [result]
								(->> result
									(map (fn [r] (dissoc r :block/children)))
									  (sort-by (fn [r] (get r :block/priority "Z")))
			  :collapsed? false}

Thank you. It seems that is works with SCHEDULED and DEADLINE, but not with regular date marker. Any help on it?

I’m really new to Datalog/Datomic, but this seems to work for me after fiddling around:

{:title "Undated"
:query [:find (pull ?b [*])
        [?b :block/marker ?marker]
        [(contains? #{"NOW" "LATER" "DOING" "TODO" "WAITING"} ?marker)]
        (not [?b :block/ref-pages ?p]
             [?p :block/journal? true]) ]
:collapsed? false}]}

I don’t fully understand why it works, so there may be some flaws in this.

Hope it helps!


I’m no datalog expert but figured I could give a shallow reading of that code in case others come here and wonder what it does.

In order of appearance, here’s what this Datalog query does:

  • Create a :query to :find an entity assigned to the variable ?b (you could also call it ?block to make this more readable at a glance. This is a pull query, which applies a search pattern to a hierarchical collection of entities.
    • Map the entity ?b to a result a result…
      • :where the entity is a :block with an attribute marker
      • and the given entity contains? the one of the following in its content: ${"NOW "LATER" …
      • and the given entity does not reference a journal page (not 100% sure I’ve interpreted this one correctly)

You can find the datomic query documentation here. In particular, if you plan to write more datomic queries going forward, this query reference is very handy.


Thank you! Great suggestion on renaming ?b to ?block. I didn’t fully realize that this was essentially a variable that I defined. Could you explain how the ?p works?

I’m still not exactly sure what :block/ref-pages and :block/journal are, wasn’t able to find any documentation on it.

If you have enable Settings > Advanced > Developer mode

you can right-click on blocks or pages and see block data

What they are used for: db-schema

:block/journal  boolean, is this a journal true/false
:block/ref-pages  links to the page the TODO is found on