Bases filter for "title startsWith today's date as YYYY-MM string"

Help!
I have this field in yaml for all my notes that adds the date as a prefix to my titles:
titledate: 2025-08-27 BBQ Installation

I want to create a base view for “This month”, i.e.,
All titledate files that begin with today's year and month as strings.

This works, of course, because I manually entered the date:
titledate.startsWith("2025-08")

I can’t seem to translate that date into an automatic string from Today’s date formatted as (“YYYY-MM”). I’ve tried:

titledate.startsWith(today("YYYY-MM").toString())
titledate.startsWith.toString(today("YYYY-MM"))
titledate.startsWith(toString(today("YYYY-MM")))

I’ll also want to create one for “last month” and “this month”. Not sure how I’ll swing that one. I know how to create that in dataview and dataviewjs, but I’m not used to bases yet.

To turn today into a string with the default format YYYY-MM-DD:

today().toString()

To customize the string format:

today().format("YYYY-MM")

To get a real date out of titledate:

date(titledate.slice(0,10))

Those give you lots of options for comparisons. Examples…

Notes from this month:

today().format("YYYY-MM") == titledate.slice(0,7)

or

today().format("YM") == date(titledate.slice(0,10)).format("YM")

Notes from last month:

(today() - "1 M").format("YYYY-MM") == titledate.slice(0,7)

Notes from this week:

today().format("Yw") == date(titledate.slice(0,10)).format("Yw")

Notes from last year:

(today() - "1 y").format("YYYY") == titledate.slice(0,4)
2 Likes

dawni, thank you so much! I truly appreciate the detail and all of the examples. This is exactly what I was looking for, and more. Much appreciated.

1 Like

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