Query TODOs created today

Hi, I appreciate the help. I need to run a logseq query that returns the tasks created today, not just those in the journal but also those created on any page. Google returns the following code, but it doesn’t give any results.

#+BEGIN_QUERY
{:title "TODOs created today"
 :query [:find (pull ?b [*])
  :in $ ?start ?end
  :where
   [?b :block/created-at ?created-at]
   [(>= ?created-at ?start)]
   [(< ?created-at ?end)]
   [?b :block/marker "TODO"]]
 :inputs [:today-start :today-end]
}
#+END_QUERY

Ensure that in file config.edn the option :feature/enable-block-timestamps? is set to true.

1 Like

The option was not activated, I activated it but there are still no results with the query.

  • Old TODO s don’t get timestamps after activating the setting.
    • Try with a new TODO.
  • Also all timestamps break on every re-index, as they are saved in the database.

Thank you, the query is now working and sorry for the basic question.

The query returns results, but if the computer is turned off and then turned back on, the results disappear and only tasks created from that moment on appear as query results.

  • I don’t see how this could happen, other than the day changing between turning off and back on.
    • Essentially every time the day changes (i.e. midnight), the query filters out all TODO s.
  • You may want a second query where to replace :today-start with :yesterday.

I appreciate the additional solution that allows you to check the tasks from the previous day, but that’s not what I’m talking about. I turned off the device at 10:00 AM and turned it on at 11:20 AM, and the tasks from that same day that were previously listed in the results were no longer there. However, the ones I added later do appear. They don’t disappear when I close Logseq, only when I restart the device. Thanks for the help.

  • Ensure that restarting the device doesn’t mess with the system’s date/time.
    • Low chances, but cannot exclude it.
  • Try re-adding the query in a new block:
    • If the new query works, delete the old block.
    • If the new query doesn’t work, try again in a new graph:
      • If the new graph works, something is corrupted in the old graph.
      • If the new graph doesn’t work, it has to be a bug, but I cannot reproduce it.
        • In that case we should look for alternative workflows.
  • All in all, should make some more tests in order to narrow down the source of the problem.
1 Like

When checking the time settings, it was updated automatically, but the time zone was not updated automatically. When activating the option and testing, the results no longer disappear. I tried restarting the computer several times. Thanks.