How to get tracker/dataview to work when file format consists of date and a suffix

Things I have tried

Hi folks, I am pretty new to the magic of obsidian. I used it now for about half a year and slowly get a glimpse of its power underneath.

Now I’d like to use the tracker and or dataview plugin that doesn’t like the naming of my daily notes. As my files are not named “2023-01-11” but “230111 - Friday - Jump” I can’t seem to get the date properly out of the filename.

I tried this here to no avail:

table date(regexreplace(file.name, "^.*(\d\d\d\d\d\d).*$", "$1")) as date from "00_Trades" sort date desc

I am also wondering how this should be included in the code …

Does anyone have an idea?

What I’m trying to do

Are your daily notes grouped together in a given folder? Are they tagged with something making them easy accessible for scripts/queries? Do you have many daily notes as of today?

The reason I’m asking, is that I would strongly suggest going over all of your daily notes and add the date field in the frontmatter, with a proper date as recognised by dataview.

This should be somewhat easily reproducable by your date resembling part of the note name, but it would better to rewrite all your daily notes into using the date field, than always keep converting the date in your queries all over the place.

In addition if you use a template to create your daily notes, please do add logic to automatically create a date field like date: 2023-01-11 into the newly created daily note.

If you don’t want to change that, you could add the FLATTEN from this example query, and then use fDate in your query as a proper date.

TABLE fDate
FROM #f52039 
FLATTEN date(regexreplace(
    file.name, 
    "^([0-9]{2})(0[1-9]|1[0-2])([0-1][0-9]|3[0-1]).*",
    "20$1-$2-$3")) as fDate
WHERE fDate
```

This will only allow proper month numbers, and proper day numbers, and assumes all years are in 20xx. If it properly manages to make this into a date, you can use WHERE fDate to filter out all notes matching this format, and having a legit date.