Queries for task management

Hi all. Is there a way to make the Todo scheduled appear only after the date and time is overdue? I know how to do only date, what about time?

Unfortunately no. Time is not stored as an attribute and so is just plain text in the block content.
Likewise the only input we have for current time is an epoch timestamp and not plain text.
I feel the scheduled/deadline implementation is very lacking in that sense.
Should be a feature request to make the time an attribute in the form of epoch timestamp as well so we can more easily get the correct tasks.


I agree that it is a pity

Hi all.
Do you know what is the syntax to have the TODO scheduled for today not recurring?

Add (not [?b :block/repeated? true])
This is an attribute that gets added specifically for repeating tasks.
Other tasks do not get a repeated false setting (not sure if never), so instead we check that they don’t have the attribute set to true specifically instead of checking they have it set to false.

1 Like

You know everything!!! :heart: :heart: :heart: :heart: :heart:

1 Like

Is there a way to have a table view with
| priority | Deadline | block (aka the text of the todo) | page
I’m trying to do this on my own with :result-transform and :view but I really cannot figure it out

Thanks for the help

1 Like

Yes, here you go:

{:title [:h3 "Custom table"]
 :query [:find (pull ?b [*])
   [?b :block/marker "TODO"]
 :result-transform (fn [result] result)
 :view (fn [rows] [:table 
 [:thead [:tr 
   [:th "Priority"]
   [:th "Deadline"]
   [:th "Task"]
   [:th "Page"]
 ] ]
 [:tbody (for [r rows
   :let [firstline (first (str/split-lines (get r :block/content)))]
   :let [rx (re-pattern "\\[#\\w\\] ")]
   :let [content (str/replace (str/replace firstline "TODO " "") rx "")]
  ] [:tr 
   [:td (get-in r [:block/priority]) ]
   [:td (get-in r [:block/deadline]) ]
   [:td content ]
   [:td (get-in r [:block/page :block/original-name])]


Hello Siferiax.
I’ve read through all queries to try to find something I need so I can kind of adapt what I’m trying to do with tasks, but I did not find anything that is really helpful in this sense still. Perhaps a Logseq limitation?
I was going to learn datalog only so I can try to solve it myself, but this is something I need to solve as soon as possible so I can start to use this tool as it would be a perfect combination of a journal to me and a task/project management.
Okay, so this is what I’m thinking for a solution to using Logseq as a project management tool; I have it organized in a way that:

  • Each project has its own page; for subprojects (if they should exist), for now I’d keep them on the same page like sub-bullet points
  • Each project will have a set of task and subtasks that might be nested in sub sub sub… sub bullet points. An example below of a task that might have some sub tasks:
[] Fix network issues
   [] Buy router
      [x] WAIT Ask Angela for a quotation [at]angela SCHEDULED:<2023-10-10>
      [x] Approve
      [x] WAIT Angela buys it [at]angela DEADLINE:<2023-11-01>
      [] Router is delivered
   [] Install router
   [] Configure it

First, you’ll see some “[at]name” scattered; this is to avoid mentioning members unwillingly. So, as an example, [at]siferiax should be interpreted as @Siferiax (which is what I’m really using in Logseq)

In my example above, we can assume that the subtask “Buy router” tasks can only be achieved once the sub sub task “Router is delivered” is finished, correct? Then, once the router is delivered, I’d mark it done, then mark “buy router” done and the next tasks would be “Install router” and “Configure it”. Once it is configured, the main task “Fix network issues” would then finally be completed.
Now, what I’d like to do (and that might be too complex (or not)) was to have a query that would would show only the “Router is delivered” one in my daily journal, for example. All the other ones can be ignored.

Now, let’s imagine that no tasks are ticket; the next one would be “Ask Angela for a quotation”. You can see that the tasks that has WAIT and “[at]angela” are to be considered “delegated” tasks, but the quotation one comes before “Angela buys it”. So, here, there would be other two queries:

  • One for retrieving only Angela’s next action (quotation) and not showing the “Angela buys it” one, similar to the first one. It should handle other people as well (let’s say I have some other colleagues (Marcus, Romero, Gotardo…) scattered in Logseq (always with an “@” before the name) and it is grouped by “DEADLINE” and then by “SCHEDULED”. The point of it is going through tasks I should be checking with my colleagues when the dates are arriving.
  • Another to group “[at]angela”'s delegated tasks (let’s say that there are other nested tasks below a major parent one and even other delegated tasks in other projects. It should deal with [at]marcus, [at]romero, [at]gotardo tasks and group it by name, alphabetically. The point of this is to complement the previous one; let’s say that [at]gotardo has something with the deadline for the current week and I’ll have to talk to him; this query will show other ones that I can talk through in a meeting, for example.

I believe the last query is easy enough (I’ll try to do it myself), but for the other ones I believe that there is no solution… perhaps? If this can be implemented, my workflow would be golden. Thanks in advance, @Siferiax

Good afternoon and tell me how to make a request so that only tasks containing TODO [#A] are shown

Wow, this is amazing, thanks!

Now i could start to switch and using Logseq also for tasks.
Only problem is that on Android they don’t come in notifications.

Before i start to learn more about the logseq queries;
Would it be possible to have in this ‘task table’ the page title clickable to go directly to that page?

Yes, we need to make it a link

[:td (get-in r [:block/page :block/original-name])]

With the following

[:td [:a {:href 
       (str "#/page/" (clojure.string/replace (get-in r [:block/page :block/original-name]) "/" "%2F"))} 
         (get-in r [:block/page :block/original-name])] 
1 Like

Hello. This can be done with simple queries.
The [#A] indicates priority.
{{query (and (task TODO) (priority A))}}

That’s a very complicated question.
I wouldn’t outright say impossible though.

I’m right now not capable of writing these types of queries due to irl limitations.

However, to give you some pointers.
We can check with :block/parent for tasks that are the parent of a given task. With this in reverse we can find children. This thread should have a rule example to recursively search for parents/children.

Similarly we can use :block/left to check for any “block to the left” of the current block. This would be a sibling. There should be an example of such a thing somewhere on this forum as well I believe.

Taken together we can say such things as no children or higher siblings should have the state todo.

Hope that helps you with the direction to think in. Sorry I cannot be of more help right now.

hola soy nuevo en logseq y nevesito ayuda , me pararece un sistema increíblemente bueno …pero esto algo desorientado, debo trabajar con mi agenda y ordenar mis tareas por eso entre aquí , me puedes orientar … se me complica también la traduccion de idioma así que si explicas con mas detalle seria de mucha ayuda . supongo que los códigos que escribes son para usar en consultas query verdad?? pero como funciona donde se debo copiar para poder utilizarlo … muy buen trabajo y mil gracias por tu ayuda ,

:wave:t3::woman_shrugging:t4: I’m sorry I don’t understand this language.

Hello, I’m new to logseq and I need some help, it seems like an incredibly good system… but I’m a little disoriented, I have to work with my agenda and organize my tasks, so come here, can you guide me??.. my language is Spanish, so it’s complicated for me as well. The translation, so I ask you if you can explain it to me in as much detail as possible, it will be an excellent help. I assume that the codes you write are to be used in query queries, right? but how does it work, where should it be installed or pasted to be able to use it…?? Very good job in advance and thank you for your help and patience,


So if you’re new it is good to first get a bit familiar with Logseq as a whole.
But to stay with queries, they can be put on any page.
For example I have a tasks page which has these queries on it. That way I have an overview of my tasks no matter where they are.
As a very basic example I go to today’s journal page. (Default startpage of Logseq)
And there I will create a task in the first block and a query in the second block

- TODO This is a task
- {{query (task TODO)}}

This will result in:

This is a simple query. For simple queries there is a user interface for simply choosing relevant options.
This thread lists mostly advanced queries. So instead of {{query (task TODO)}} the block would have one of the full codes from this thread.
A full code means that it starts with #+BEGIN_QUERY and ends with #+END_QUERY.
I hope that helps. Feel free to ask any follow up questions.

@Tiago_Melo This took a couple of hours lol, but I think I managed to get this working as you described!!

It now looks at all tasks anywhere, but you can of course add extra filtering.

{:title [:b "Next Task"]
 :query [:find (pull ?b [*])
  :in $ %
   [?b :block/marker "TODO"]
   [?b :block/parent ?t]
   (not ; ?b doesn't have an open child.
     [?c :block/parent ?b]
     [?c :block/marker "TODO"]
   (not (findleft ?b) ) ; ?b doesn't have an earlier task in the list
 :rules [
  [(findleft ?b)
    [?b :block/parent ?m]
    (not [?m :block/name])
    [?b :block/left ?l]
    [(!= ?l ?m)]
    [?l :block/marker "TODO"]
  [(findleft ?b)
    [?b :block/parent ?m]
    (findleft ?m)

@Siferiax i need your help.
I would to have one query inside a parent block looking for TODO but excluding the todo already referenced inside that parent block.
I hope it is clear enough