Events and anniversaries, redux

More than a year after posting Events and anniversaries - Help - Obsidian Forum, I found the solution, and I thought I’d share.

In my notes I use a tag “contact” for some people, and I have a dates property with a list of things I’d like to remember about them. I use the format:

dates:
- "2023-06-01: Start looking for a way to retrieve dates"
- "2024-07-18: Found the solution, and I'm going to celebrate every year"
- "1980-03-05: Birthday"

In a “Reminders” note, I use the following dataview queries to help me see reminders for today and this week.

Reminders for today

LIST
  event
FROM
  #contact
WHERE
  contains(file.frontmatter, "dates")
FLATTEN
  dates AS reminder
FLATTEN
  date(split(reminder, ": ")[0])
  AS
  date
WHERE
  dateformat(date, "MM-dd") >= dateformat(date(now), "MM-dd")
  AND
  dateformat(date, "MM-dd") <= dateformat(date(now), "MM-dd")
FLATTEN
  split(reminder, ": ")[1] + " (" + dateformat(date, "d MMM") + ", " + durationformat(date(now) - date, "y") + ")"
  AS
  event
SORT
  dateformat(date, "MM-dd") asc

Reminders for this week

LIST
  event
FROM
  #contact
WHERE
  contains(file.frontmatter, "dates")
FLATTEN
  dates AS reminder
FLATTEN
  date(split(reminder, ": ")[0]) AS date
WHERE
  dateformat(date, "MM-dd") >= dateformat(date(sow), "MM-dd")
  AND
  dateformat(date, "MM-dd") <= dateformat(date(eow), "MM-dd")
FLATTEN
  split(reminder, ": ")[1] AS event_note
 FLATTEN
   dateformat(date, "d MMM") AS event_date
 FLATTEN
   durationformat(date(eow) - date, "y") AS event_age
 FLATTEN
   event_note + " (" + event_date + ", " + event_age + ")" AS event
SORT
  event_age DESC
SORT
  dateformat(date, "MM-dd") ASC

Hopefully it helps someone else, too!

THANK YOU SO MUCH! I have wrestled so much with how to include events/birthdays/anniversaries in my Obsidian data, and before you shared this code, I had ended up making individual notes for each event, which was highly un-ideal. Your code works right away for me in my vault, allowing me to enter multiple dates per file and have the age too - WOW

I did a bit of tweaking, because for recurring events I don’t know the initiating year for I always use the year 1098 by personal convention (leading to large and meaningless ages), and I also didn’t want to have the “(0)” show for all things that I have down for this year. This is an in-elegant way to not have duration-years for those events - it will break down as soon as I know someone older than 100 :slight_smile:

FLATTEN
durationformat(date(eoy) - date, “y”) AS event_age
Flatten
choice(2024-date.year=0, 200 , event_age) as event_ages
FLATTEN
event_note + choice(number(string(event_ages)) < 100, " (" + event_ages + ") ", " ") AS event

1 Like

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