Query for scheduled events with custom view and date formatting?

I’m struggling with an advanced query. The goal is very simple, so probably someone did it already, but I want to customize the view, and this is the tricky and novel part.

I want a list of the next SCHEDULED events, for 15 days ahead. The output should be in table format ordered by the scheduled date. The first column should be the scheduled date, and should be clickable and lead to the journal page of the target date. The second column should be the block content (which contains the SCHEDULED state), and should be clickable and lead to that block.

I already achieved some of the goals. I could get the scheduled events, sort them by scheduled date, and format the output as a table, and even to make the text on second column clickable. This is my code:

#+BEGIN_QUERY
{:title "Scheduled appointments, 15 days from today"
 :query [:find (pull ?block [*])
         :in $ ?start ?next
         :where
         (or
           [?block :block/scheduled ?d]
          ;; [?block :block/deadline ?d]
         )
         [(> ?d ?start)]
         [(< ?d ?next)]
        ]
 :result-transform (fn [result]
   (sort-by (fn [d]  (get d :block/scheduled)) result))
 :view (fn [rows] [:table
    [:thead [:tr   [:th "Date"] [:th "Description"]]]
    [:tbody (for [r rows :let [sched (str (get r :block/scheduled))]]
            [:tr
              [:td (str sched)]
              [:td [:a {:href (str "#/page/" (get r :block/uuid))} (get r :block/content)]]
            ])
    ]])
:inputs [:today :15d-after]
}
#+END_QUERY

This is an example of the output:

|-----------|-----------------------------------------------|
| Date	    | Description                                   |
|-----------|-----------------------------------------------|
| 20220419	| Next Meeting with [[Mark]]                    |
|           | SCHEDULED: <2022-04-19 Tue 11:00>             |
| 20220420	| Next Meeting with [[Irv]]                     |
|           | SCHEDULED: <2022-04-20 Wed 17:00>             |
| 20220421	| Next Meeting with [[Holly]]                   |
|           | SCHEDULED: <2022-04-21 Thu 11:30>             |
|-----------|-----------------------------------------------|

This works nicely but has some unresolved points:

  1. Cliking the contents of the second column correctly leads to the block with that content. But Shift+click does not work to open it in the sidebar, and hovering does not show that content either.
  2. The first column show the scheduled date as 20220414 for example, instead of “2022-04-14 Tuesday”
  3. The first column is not clickable

What I need now is some way to parse the contents of the variable sched in my query to get the date, and apply to it the proper format (preferably the one selected by the user in preferences). This way I can create an anchor with href pointing to that journal page.

I don’t know a word about Clojure. Most to the code above was written by trial and error. I start to grasp the basics, but I don’t know if clojure provides date parsing mechanisms, or if those are provided by another library, and in this case if that library is accessible from query code.

I tried looking at logseq/date.cljs at master · logseq/logseq · GitHub but I didn’t find anything useful. And even if an appropriate function was defined here, I would not know how to use it from my query