Dynamic link to yesterdays daily note with specific date formatting

Your suggestion will keep changing to always link to yesterday, and not take into consideration what the actual date of today is…

A better solution would be to use something like: `= link(dateformat(this.file.day - dur(1day), “yyyy-MM-dd-ccc”), “Yesterday”) ` where we create the link based upon the date used in the file name.

Some key points why this works:

  • this.file.day – Will pull the date either from the file name, or a property called date. Since your file name includes the proper YYYY-MM-DD somewhere in the file name, it’ll use this
  • Build the entire link – It’s safer to build the entire link within the query, instead of partically patching together the [[ and so on. Doing the entire link gives a proper rendering in more cases, whilst patching it together requires some rendering magic to happen later on (which often is the case, but not always)
  • Luxon vs moment date formatting tokens – Many plugins (and Obisdian core) mainly uses moment date formatting tokens, where YYYY-MM-DD-ddd would denote your date string. But Dataview, and some other plugins, uses Luxon date formatting token, so the equivalent would therefore be: yyyy-MM-dd-ccc. See dateformat(), and here is an online tool converting from momemt to Luxon: https://moment-to-luxon.vercel.app