Advanced Query for property "due-by" between 7 and 30 days from now, sorted by due-date and priority

status is always a single hashtag-value property. Thanks for the clarification as it adds to the knowledge embedded in this single query :slight_smile:

#+BEGIN_QUERY
{:title [:h3 "Soon... (7-30 days):"]
 :inputs [:+7d :+30d]
 :query [:find (pull ?b [*])
  :in $ ?start ?next
  :where
   [?b :block/properties-text-values ?textprop] ;get plain text of the properties
   [(get ?textprop :status) ?stat] ;get the status property
   [(contains? #{"#defacut" "determinat"} ?stat)]
   [?b :block/properties ?prop]
   [(get ?prop :due-by) ?due] ;get the due-by property
   [?b :block/refs ?j] ;get the block references
   [?j :block/original-name ?journal] ;get the page name of the reference
   [(contains? ?due ?journal)] ;check that the reference is actually present in the property
   [?j :block/journal-day ?d] ;get the date of the journal page
   [(<= ?start ?d ?next)] ;check that the journal page is in range
   [(get ?prop :priority) ?stat] ;get the status property
 ]
 :breadcrumb-show? false
}
#+END_QUERY

I will have to add even more to it, like sorting the results by date-approaching combined with yet another property priority :slight_smile: but I first have to figure out how to give priorities some order beyond that based on their name (because the first letter in the naming has nothing to do with the urgency level). If only properties could have sub-properties :slight_smile: