Records up to a certain journal day for X days

I want to query records up to a certain journal day with hashtag #dayreview for X days, but my query is not working…

#+BEGIN_QUERY
{ 
   :query [
           :find (pull ?b [*])
           :in $ ?tag
           :where
           [?p :block/name ?tag]
           [?b :block/refs ?p]
           [?p :block/journal? true]
           [?p :block/journal-day ?day]
           [(>= ?day :-14d)]
           [(<= ?day :0d)]
   ]
    :inputs ["dayreview"]
}
#+END_QUERY

Can you please tell me where I made a mistake?

:-14d and :0d are Relative date inputs and should be provided to :inputs , not directly inside :where

Thanks for the quick response.
I fixed my query, but it still doesn’t work.

#+BEGIN_QUERY
{ 
   :query [
           :find (pull ?b [*])
           :in $ ?start ?end
           :where
           [?p :block/name ?tag]
           [?b :block/refs ?p]
           [(contains? #{"dayReview"} ?tag)]
           [?p :block/journal? true]
           [?p :block/journal-day ?day]
           [(>= ?day ?start)]
           [(<= ?day ?end)]
   ]
    :inputs [:-14d :0d]
}
#+END_QUERY

If you remove the line [(contains? #{“dayReview”} ?tag)], it gives some data.
But with this line of code, it doesn’t show anything.

  • :block/name returns names always in lower-case. Either:
    • use :block/original-name
    • replace #{"dayReview"} with #{"dayreview"}
  • for single value, could also use (= "..." instead of (contains? #{"..."}

Tried different variants, but it still doesn’t work either.

The idea was to make every day a record like this: log:: Today was a good day #dayreview and for every Sunday create a weekly review template with this query to collect these records for the past week as a table with date.
I can’t think of a better way to do a weekly review yet )

  • Try focusing each thread on a single topic.
  • log:: is a property, but your query has nothing relevant to it.
  • :-14d is two weeks instead of one.
  • “doesn’t work” says nothing useful.
    • A single mistake is enough to break the whole query.
      • Datalog doesn’t forgive any mistake.
    • Before succeeding with a single complicated query, make multiple simpler ones that actually work:
      • a query that returns all blocks with #dayreview
      • a query that returns all blocks from the last 2 days
    • Preferably experiment on a small testing graph.
    • To receive the best help, you need to provide the best description of your effort.
      • People cannot guess what you do wrongly.

This example in documentation is basically what you are after.
Replace input fields with values to suit your needs
https://docs.logseq.com/#/page/63b70dc8-1d59-4348-9737-e62b17fdabca

Thank you for the answer. We can try to modify this query to suit our needs.

But the problem is that the query works always and every day will show different values.

I wanted to bind to journal-day, to query records for a certain week and instead of ‘:today’ , write something like ‘:journal-day’ (as I understand there is no such command).

I wanted to make a template with this query for each Sunday to collect all values like an overview of the past week.

I don’t know how to implement this.
(Don’t speak English, use translator)