Ok, so I don’t know if there would be an easier way
… But I think I was able to make it work in DQL using RegEx to “rewrite” the date into a date Luxon can read (and therefore Dataview too)
…
```dataview
TABLE WITHOUT ID
file.link as "All Daily Notes"
FROM #dailynotes
WHERE file.name != "Daily Note Template"
SORT date(regexreplace(file.name, "(\w{3}) (\d{1,2})(th|st|nd|rd), (\d{4})", "$4-$1-$2"), "yyyy-MMM-d") DESC
```
I’m absolutely no RegEx expert but in some kind of summary, the regexreplace()
:
regexreplace(file.name, "(\w{3}) (\d{1,2})(th|st|nd|rd), (\d{4})", "$4-$1-$2")
(Regex101 test)
Captures, from the file.name
:
- Group 1 (
$1
): the “month part” composed of exactly 3 “word character” ( → (\w{3})
)
- Group 2 (
$2
): 1 or 2 digits ( → (\d{1,2})
)
- Group 3 (
$3
): Either the characters th
or st
or nd
or rd
( → (th|st|nd|rd)
)
- Group 4 (
$4
): Exactly 4 digits ( → (\d{4})
)
Which are then “re-ordered” as $4-$1-$2
which can somewhat be translated, following MomentJS syntax as YYYY-MMM-D
, equivalent in Luxon to yyyy-MMM-d
… which can then be parsed as a date Dataview/Luxon should be able to understand within the DQL and used to sort the results of the query
.
And now that I wrote all this, I’m thinking that simply replacing the (th|st|nd|rd)
by “blank” (""
) could be largely enough
…
Well, I’m going to leave it, just in case
… but a simpler way to get to similar results in DQL could be:
```dataview
TABLE WITHOUT ID
file.link as "All Daily Notes"
FROM #dailynotes
WHERE file.name != "Daily Note Template"
SORT date(regexreplace(file.name, "(th|st|nd|rd)", ""), "MMM d, yyyy") DESC
```
(Regex101 test is here but fairly untested with Dataview though
)