Query with exact date

Hi!

I’m a new user of logseq and I’m trying to create a page with a weekly summary. I want to use queries to show the “slipping” tasks from the previous week and a summary of tasks from the current week.
I found an interesting example in docs on advanced queries, but all the examples there use relative dates such as “:today”, “:7d-after”, and similar. I’ve been trying to put exact dates such as “26-07-2021” or “2021-07-26”, but the query either does not compiler or comes back empty.

#+BEGIN_QUERY
{:title "🟠 SLIPPING"
 :query [:find (pull ?b [*])
   :in $ ?start ?today
   :where
   [?b :block/marker ?marker]
   [?b :block/page ?p]
   [?p :page/journal? true]
   [?p :page/journal-day ?d]
   [(>= ?d ?start)]
   [(<= ?d ?today)]
   [(contains? #{"NOW" "LATER" "TODO" "DOING"} ?marker)]]
   :inputs ["2021-07-26" "2021-07-28"]
   :result-transform (fn [result]
                            (sort-by (fn [h]
                                       (get h :block/created-at)) result))
}
#+END_QUERY

What’s the trick to make it work?

3 Likes

I had the same question today. After searching in the logseq codebase, I found out the expect an integer with the format of YYYMMDD (no space). In the code, they cast the date into string, then remove the separator.

So to use fixed / specific dates in logseq query, you can use something like this:

:inputs [20210726 20210728]
1 Like

so how would I combine it in a regular query with a page reference for example? All of the following fails :frowning:

{{query (and [[sport]] (between 20220419 20220510))}}
{{query (and [[sport]] [20220419 20220510])}}

You have to insert the dates as links.

{{query (and [[sport]] (between [[Apr 19th, 2022]] [[May 10th, 2022]]))}}
1 Like

Yes, you are right! Thanks!