Hello everyone, I want to query a specific block of yesterday in today’s note, but the inputs here can only enter the time based on today. I hope that when I check the note from 3 days ago today, the results of the query there are from 4 days ago.
Thanks for everyone’s help
this is my current queries
#+BEGIN_QUERY
{:title [ "📄 Yesterday Things" ]
:query [:find (pull ?b [* {:block/_parent ...}])
:in $ ?end
:where
[?b :block/page ?p]
[?p :page/journal? true]
[?b :block/refs ?ref]
[?ref :page/name "明日安排"]
[?p :page/created-at ?v]
[(- ?end 86400000000 ) ?period]
[(>= ?v ?period)]
[(< ?v ?end)]
]
:inputs [:start-of-today-ms]
}
#+END_QUERY
If you are looking for blocks on yesterday’s journal page you can do that without timestamps.
You can use attribute :block/journal-day
to get the day of that journal.
And you can use input :yesterday
to get yesterday’s date. Or can do :-1d
and change the 1 to desired number of days.
Then in your query you can simply say either.
#+BEGIN_QUERY
{:title [ "📄 Yesterday Things" ]
:query [:find (pull ?b [* {:block/_parent ...}])
:in $ ?yesterday
:where
[?p :block/journal-day ?yesterday]
[?b :block/page ?p]
[?b :block/refs ?ref]
[?ref :page/name "明日安排"]
]
:inputs [:yesterday]
}
#+END_QUERY
Or if you wish a certain range of dates you could do something like
#+BEGIN_QUERY
{:title [ "📄 Yesterday Things" ]
:query [:find (pull ?b [* {:block/_parent ...}])
:in $ ?yesterday ?start
:where
[?p :block/journal-day ?day]
[(<= ?start ?day ?yesterday)]
[?b :block/page ?p]
[?b :block/refs ?ref]
[?ref :page/name "明日安排"]
]
:inputs [:yesterday :-3d]
}
#+END_QUERY