Query for all tasks Scheduled or deadlined for today. Can anyone help with this?

Hi there,

I have been looking for hours but couldn’t find how to achieve it. Anyone knows how to query for all tasks scheduled or deadlined for today?

Thanks very much!

There’s a lot of task related queries here:

Though I don’t think this one specifically.

So here’s your specific one:

#+BEGIN_QUERY
{:title [:b "Today's tasks"]
 :query [:find (pull ?b [*])
  :in $ ?day
  :where
   [?b :block/marker ?m]
   [(contains? #{"TODO" "DOING"} ?m)]
   (or
     [?b :block/scheduled ?day]
     [?b :block/deadline ?day]
   )
 ]
 :inputs [:today]
}
#+END_QUERY
1 Like

Is there a way to adapt this query to pull tasks that are scheduled for the current day by the repeater? For example, if the current day is 2023-11-23, pull the task marked SCHEDULED: <2023-11-21 Tue .+2d> as well.

The idea of the repeater is that when you mark a task as done it will move the scheduled date the desired amount of time from the original scheduled date.
So in this case from 21st of Nov to 23rd.
As the repeater in the data only exists as plain text, it is not (easily) possible to get the data and modify the date. We have no date manipulation functions as a date format isn’t implemented in advanced queries.
In other words the ?day in the query is not a date but actually a number e.g. 20231123.

1 Like

Appreciate the snippets here, still learning queries!

I’m using this slightly differently–for high priority tasks that are due today (or in the past)–I dropped the Scheduled aspect since I’m already capturing that in other queries.

Dropping my query here if it’s helpful to anyone:

#+BEGIN_QUERY
{:title [:b “:exclamation: Do Due Tasks!”]
:query [:find (pull ?b [*])
:in $ ?day
:where
[?b :block/marker ?m]
[(contains? #{“TODO” “DOING”} ?m)]
[?b :block/deadline ?d]
[(<= ?d ?day)]
]
:inputs [:today]
}
#+END_QUERY