I want to create a logseq query that queries task that is scheduled tomorrow
- User
I want to create a logseq query that queries task that is scheduled tomorrow
Assistant
Here's a Logseq query that will show you all tasks scheduled for tomorrow.
Logseq's query language is powerful and allows for relative dates, which is perfect for this.
#+BEGIN_QUERY {:title "🗓️ Tasks Scheduled for Tomorrow" :query [:find (pull ?block [*]) :where [?block :block/marker ?marker] [(contains? #{"TODO" "DOING" "NOW" "LATER" "WAITING"} ?marker)] ; Only active tasks [:< ?block :block/scheduled :tomorrow] ; This is the core part! ] :result-transform (fn [result] (sort-by (fn [h] (get-in h [:block/scheduled])) result)) :group-by-page? false :breadcrumb-show? true :collapsed? false } #+END_QUERYExplanation of the Query:
-
#+BEGIN_QUERY/#+END_QUERY: These lines are Logseq's way of indicating a query block. -
:title "🗓️ Tasks Scheduled for Tomorrow": This sets the title that will appear above your query results. You can customize this. -
:query [:find (pull ?block [*]) :where ...]: This is the main query logic.:find (pull ?block [*]): This tells Logseq to find blocks (?block) and pull all their properties ([*]).:where: This defines the conditions for the blocks to be included in the results.[?block :block/marker ?marker]: Ensures the block is a task (i.e., has a marker like TODO, DONE, etc.).[(contains? #{"TODO" "DOING" "NOW" "LATER" "WAITING"} ?marker)]: This filters the results to only show "active" tasks. If you want to includeDONEtasks, you can add it to this set. If you want all tasks regardless of status, remove this line entirely.[:< ?block :block/scheduled :tomorrow]: This is the crucial part.:block/scheduled: Targets theSCHEDULED:property of a block.:tomorrow: This is a Logseq keyword that dynamically resolves to tomorrow's date. The<is often used with:scheduledand a date keyword to mean "scheduled on that specific date".
-
:result-transform (fn [result] (sort-by (fn [h] (get-in h [:block/scheduled])) result)): This is an optional but highly recommended part. It sorts the results by their scheduled date, which makes them easier to read. -
:group-by-page? false: By default, Logseq groups query results by the page they belong to. Setting this tofalselists them directly, which is often preferred for task lists. -
:breadcrumb-show? true: Shows the page path for each task, which helps you know where the task originated. -
:collapsed? false: Keeps the query results expanded by default. Change totrueif you want them collapsed.
How to use it:
- Go to any page in your Logseq graph (e.g., your
daily journalpage, aninboxpage, or a dedicateddashboardpage). - Type
/Queryand select "Query" from the pop-up menu, or simply type#+BEGIN_QUERYand press enter. - Paste the entire query block above into your Logseq page.
- Click out of the block, and the query results will appear.
Example Task (that would be included):
Let's say today is October 26, 2023.
- TODO Call client about project update SCHEDULED: <2023-10-27 Fri>This task would appear in the query results.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.