How to query for post-due dates (`due` is a property)

I have a project templates look like this:


projects/sample-project
project-name:: this is the full name of the project
due:: 2023-10-31


Now I want to a query in my main project entrance that looks like this

How do I write this kind of functions?

Is this what you’re looking for?

#+BEGIN_QUERY
{:title [:b "Projects past due"]
 :inputs [:query-page :today]
 :query [:find (pull ?p [*])
  :in $ ?page ?today
  :where
   [?prj :block/name ?page]
   [?p :block/namespace ?prj]
   [?p :block/properties ?prop]
   [(get ?prop :due) ?due]
   [(re-pattern "(\\d{4})-(\\d{2})-(\\d{2})") ?rx]
   [(re-find ?rx ?due) [_ ?yyyy ?mm ?dd]]
   [(str ?yyyy ?mm ?dd) ?day]
   [(str ?today) ?stoday]
   [(< ?day ?stoday)]
 ]
}
#+END_QUERY

Sorry for the late response,
This is the result after input the query above
re-find must match against a string.

Does it means the [(get ?prop :due) ?due] does not assign the ?due as a string?

No worries.
It shouldn’t? If your due is formatted as you said due:: 2023-10-31 it should be a string.
Here’s a screenshot from my test graph.

Oh wow thanks for pointing it out, and sorry for my negligence.
My property is actually a link to dates in format of #[[2023-10-31]]

I modified a few lines of code as following

for some reason it shows all the project when supposedly only selected one should appear

What’s wrong with my modification?

So due will be a reference whereas today is an integer. That’s why your modification doesn’t work. However instead of properties we can use the attribute properties-text-values and due will be a string.
Like so:

#+BEGIN_QUERY
{:title [:b "Projects past due"]
 :inputs [:query-page :today]
 :query [:find (pull ?p [*])
  :in $ ?page ?today
  :where
   [?prj :block/name ?page]
   [?p :block/namespace ?prj]
   [?p :block/properties-text-values ?prop]
   [(get ?prop :due) ?due]
   [(re-pattern "(\\d{4})-(\\d{2})-(\\d{2})") ?rx]
   [(re-find ?rx ?due) [_ ?yyyy ?mm ?dd]]
   [(str ?yyyy ?mm ?dd) ?day]
   [(str ?today) ?stoday]
   [(< ?day ?stoday)]
 ]
}
#+END_QUERY