Converting list result to date

I use Obsidian to track TV episodes I’ve watched, and use a list (watched-times) to do this, by linking to the daily notes of hen I watched. I have a base to filter episodes watched in 2025, times-watched: note[watched-times].filter(value.contains("2025")).

What I’m trying to do

Extract the last value input (which I can achieve with formula["times-watched"][-1], and convert it into a date (for sorting).

Things I have tried

Using the date function (with and without converting to string) — returns empty.

If it helps the files linked are in the following format: DD.MM.YYYY -- ddd|DD.MM.YYYY. I’d appreciate any help :slight_smile:

1 Like

This formula selects the last entry in times-watched and returns its link as a date that you can sort on:

date([[8,12],[5,7],[2,4]].map(note["times-watched"][-1].toString().slice(value[0],value[1])).join("-"))

It uses the same [-1] logic as your other formula to choose the last times-watched entry. So it relies on your having entered them in order.

If there’s a chance you might enter them out of order, then a more robust way to do it would be:

note["times-watched"].map(date([value.tostring().slice(8,12), value.tostring().slice(5,7), value.tostring().slice(2,4)].join("-"))).sort()[-1]

That turns all of the times-watched entries into dates then returns the most future date, which you can then sort on.

The rest of the code in both of these versions is just arranging characters into the YYYY-MM-DD format required by the date() function.

1 Like

AMAZING! Thank you so much!