Dataview list based on PREVIOUS month

To play safe, go for

WHERE file.day.month = (date(today) - dur(1 month)).month
    AND file.day.year = (date(today) - dur(1 month)).year

This

  • compares
    • the month from the file.day (in turn from file title or date: YAML)
  • against
    • the month calculated by subtracting a duration of 1 month from today’s date.
  • and then also compares the year since we don’t want files from last month in all years.

You could also use a string compare (by building “YYYY-MM” strings and then comparing these). Which to choose is personal style, mainly. (What is more logical to you.)

WHERE dateformat(file.day, "yyyy-MM") = dateformat(date(today)-dur(1 month), "yyyy-MM")

Problem solved! (Hopefully.)

2 Likes