Query tasks for tomorrow / today

Hello,

Sorry to trouble you all, I’ve been playing around with no joy and did do a brief search.

Is there a way to do a query that does this:

Find “now” tasks dated for today

I know how to display “now” tasks, but for example I’ve put a date on a task, and when that date becomes today, I would like just that task displayed.

Thanks in advance!

Chris

Yes, there are ways, but you are not specific enough.

  • Logseq has a built-in NOW query.
    • Find it in file config.edn
  • If by “dated for today” you mean “scheduled for today”, could use something like this:
     :inputs [:today]
     ...
       :in $ ?today
       ...
         [?b :block/scheduled ?d]
         [(= ?d ?today)]
    
  • Otherwise, be more specific by sharing:
    • some example blocks
    • your current query
1 Like

Sorry for the poor comms @mentaloid

This might be more helpful.

Say I have a page relating to changes to a room

I’ve done most tasks, but I would like to display jobs to be done today - i.e. plasterboarding (today is the 11th, the task is set for tomorrow).

So far I’m capable of give a heading and below it, a query with the simple /query option, but at the moment I can only use a date range:

{{query (task NOW) (between [[May 11th, 2025]] [[May 15th, 2025]]))}}

This provides this output

What I would like to do, is instead of giving a date range, say

show tasks 'NOW' AND for 'TODAY'.

Playing around a little further, I see that doing this query, the plasterboarding dated for 12th, is still being shown despite the date range being between 13th and 15th:

{{query (task NOW) (between [[May 13th, 2025]] [[May 15th, 2025]]))}}

I was hoping this was possible as I note the docs suggest today/tomorrow is a possible function (please excuse me if I’m using the wrong phrasing).

https://docs.logseq.com/#/page/queries

I must admit, I’m confusing things a little, because a task is not technically NOW until the date arrives. The day before the NOW task, it should not display. But on the day of the task, I would hope that it would show, because I’ve asked for “NOW” tasks to be shown “TODAY”.

I do hope that makes sense, thanks again in advance.

  • Yes, it is quite confusing to use NOW for a task that is actually for later.
    • You may prefer to just use TODO instead.
  • between range checks the journal page a task is in.
  • In contrast, your block example contains a reference to the journal page.
    • Try this advanced query:
      #+BEGIN_QUERY
      {
       :inputs [:today]
       :query [:find (pull ?b [*])
         :in $ ?today
         :where
           [?p :block/journal-day ?d]
           [(= ?d ?today)]
           [?b :block/refs ?p]
           [?b :block/marker "NOW"]
       ]
      }
      #+END_QUERY
      

Thank you @mentaloid that works perfectly, really appreciate you taking the time.

I’m going to learn about Datalog as I much prefer to know how to do these query snippets, rather than bothering the good folk such as yourself on this forum.

Thank you again :+1:

Hi Chris,

On my side I’ve slightly changed the Logseq config file config.edn and now I have this to show ongoing/scheduled tasks:

 {:journals
  [{:title "🔨 NOW"
    :query [:find (pull ?h [*])
            :in $ ?start ?today
            :where
            [?h :block/marker ?marker]
            [(contains? #{"NOW" "DOING" "WAITING"} ?marker)]
            [?h :block/page ?p]
            [?p :block/journal? true]
            [?p :block/journal-day ?d]
            [(>= ?d ?start)]
            [(<= ?d ?today)]]
    :inputs [:365d :today]
    :result-transform (fn [result]
                        (sort-by (fn [h]
                                   (get h :block/priority "Z")) result))

You can search for the journal tag and customize this section that is showing on the home page.
Hope that helps !

Julien

1 Like

Hi Julien,

Thank you very much for sharing! I’ll certainly take that for a spin and see how I go :+1:

Just out of interest, how or where did you learn to do this code?

Many thanks, Chris

The code was already there, I’ve just added the “WAITING” tasks and changed title if I remember correctly.
I think I’ve seen a post here on this forum about this customization.
Also I’ve got the Logseq newsletter to keep me updated (that’s how I saw your topic).

1 Like

Oh I see, thank you for letting me know. I was a little worried a person has to be a coding guru to get the most out of Logseq!