Possible to use recognition of a date in title to sort imported notes chronologically (1k notes)?

What I’m trying to do

As a newcomer within the Obsidian universe I am currently struggling to get my imported Journaling notes sorted chronologically. To be more specific, I have imported about 1k notes from my former journaling app (Journey). Each note has a date description as title (which I would like to use to list chronologically). However, I do not know how I could manipulate the title in such way to have them chronologically sorted in a dataview list.

Things I have tried

All the data was imported as one note. So far, I managed to split each journal entry by making use of Refactor plugin (on H1 title). Now I have approx. 1000 separate notes which all have a title explaining a date in the following syntax “mmmm dd, yyyy hhmm”, as an example: april 01, 2022 0746.

When I make a list in dataview, I generate the whole list but sorted alphabetically on the first letter of the month (so notes from different years get grouped). I have no clue so far how (or if) I can change automatically all titles, or use the title content in such way that they will list chronologically. As there is no metadata, alphabetically would be the way to go, but therefore I would need to change automatically all the note titles to a new synthax, for example: yyyy mm dd hhmm: 2022 04 01 0746

Your help is much appreciated!
Picture1

Ideally you’d insert an ISO date into the frontmatter of each file in the format of YYYY-MM-DD[T]hhmm, and then you could use this query:

```dataview
LIST
SORT file.day
```

If that’s not an option you could in some cases use date(file.name, " ??? ") where ??? is replaced with a suitable format. This would then have built a date based upon your file name. However, that function is not happy about localised names, like your month names. So then we need to do it manually like in the following query:

```dataview
LIST isoDate
WHERE file.folder = this.file.folder
  AND file != this.file
FLATTEN list(split(file.name, ",? ")) as parts
FLATTEN object(
    "january", "01",
    "february", "02",
    "march", "03",
    "april", "04",
    "may", "05",
    "june", "06",
    "july", "07",
    "august", "08",
    "september", "09",
    "october", "10",
    "november", "11",
    "december", "12")[parts[0]] as numMonth
FLATTEN join(list(parts[2], "-", numMonth, "-", parts[1], "T", parts[3]), "") as isoDate 
SORT isoDate
```

In your final query you need to replace the WHERE ... AND lines with something matching your journaling notes, and most likely you don’t need to see the isoDate so the first line could be just LIST.

What does this monstrosity do? Well…

  • First we split the file.name containing the date into its separate parts, separated by either , or a space
  • Then we declare an object with the month name as key, and the numeric version as a value, and look into this object using the first part (aka the month name). Now “january” becomes “01”, “february” becomes “02”, and so on
  • Finally we reorder all the bits and pieces into a proper isoDate, which has the attribute that alphabetical sorting is also sorted by date
  • Now we can finally do SORT isoDate to get it properly sorted

The query as it stands above with my 12 carefully named journal entries returns this output:
image

Thank you so much holroy, your query did magic! :pray:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.