Generate a list or table that lists the work anniversaries and birthdays of employees for the current month
Things I have tried
I have a file for each employee and for each employee there is a metadata property category for “Start Date” and another for “Birthday”. I created a dataview query to search for these properties but it did not work. Here is the query:
TABLE WITHOUT ID file.link AS "Note", start date AS "Start Date"
WHERE Start Date
AND ((dateformat(Start Date, "MM-dd") >= dateformat((date(today) - dur(1 weeks)), "MM-dd"))
AND (dateformat(Start Date, "MM-dd") <= dateformat((date(today) + dur(2 weeks)), "MM-dd")))
And here is what the property table looks like for each employee:
Thank you for the quick reply. I should clarify: I want the list or table to be in a summary file or dashboard file that will pull together the birthdays and anniversaries from several separate/individual files. I hope that makes sense.
It does. And the query works in my local test vault on a summary page. The original image shows it is pulling data from two sample files. There could be thousands of them and it would (or should) work. Doesn’t work for you?
```dataview
TABLE WITHOUT ID
file.link AS Name
, start-date AS "Start Date"
, Birthday
WHERE start-date
AND ((dateformat(start-date, "MM-dd") >= dateformat((date(today) - dur(1 weeks)), "MM-dd"))
AND (dateformat(start-date, "MM-dd") <= dateformat((date(today) + dur(2 weeks)), "MM-dd")))
SORT start-date ASC
```
So close. Close enough that I’m positive I’m missing a step or I just don’t have enough Obsidian understanding to get it to work. The table is showing up but it’s unpopulated.
Here’s what I’m getting with your query:
If your Start Date data is not formatted as a computer-readable ISO8601 date, perhaps the kludge below will work. Note that in the sample, Start Date is not a computer-readable date, but Birthday is. Much depends on how data is stored in its raw state. ISO8601 raw data makes queries a lot easier to code.
---
Start Date: 03-04-2021
Birthday: 1988-05-11
---
```dataview
TABLE WITHOUT ID
file.link AS Name
, dateformat(sDate, "cccc, dd MMMM yyyy") AS Started
, Birthday
FLATTEN date(string(start-date), "MM-dd-yyyy") as sDate
WHERE sDate
AND sDate.month = date(now).month
SORT sDate ASC
```
That might be the issue. The problem is that I can’t change the dates in the metadata properties at the top of the employees file to an ISO8601 format. It defaults to MM/DD/YYYY (see below). And unfortunately the possible code fix you gave isn’t working.
As raw data, are the numbers separated by forward slashes?
If so, could try:
```dataview
TABLE WITHOUT ID
file.link AS Name
, dateformat(sDate, "cccc, dd MMMM yyyy") AS Started
, Birthday
FLATTEN date(string(start-date), "MM/dd/yyyy") as sDate
WHERE sDate
AND sDate.month = date(now).month
SORT sDate ASC
```
Using ISO8601 format in a local test vault, this works:
```dataview
TABLE WITHOUT ID
file.link AS Name
, start-date AS Started
, Birthday
WHERE start-date
AND start-date.month = date(now).month
SORT start-date ASC
```
Quick follow up…is there a way to have the date displayed in the query show like this: “March 28”. Right now the result of the query code is “2025-00-28”. I’m assuming the “00” is there because March is the current month and thus is “00” month.
Apologies, I only just saw your post about the zeros in the date.
I don’t know what is happening there. In the samples I ran locally, the full date is supplied, not zeros. I really don’t know what is causing the problem, but hopefully someone else will be able to help.
If you look at the documentation for dateformat(date), it uses Luxon tokens, and there you’ll see what is legal to use as format tokens.
If you get 00 out of your tokens, it seems like you’ve written something bad into the tokens. Have you happened to switch upper- and lowercase or something like that?
Regarding your case, where it seems like you want to print the start-date similar to “March 28”, you’d use something like dateformat(start-date, "LLLL d").