Dataview + Full Calendar for daily agenda

What I’m trying to do

I’ve got a setup I am fairly happy with combining FullCalendar for to mirror a few different sources and track them, allowing me to take notes relating to specific events, tasks to track my tasks, and daily-notes pulling it all together for a “what do I need to know about today” view.

What I can’t seem to get fully sorted out is getting my recurring events from a specific day of the week (Thursdays) to show up correctly. It seems like there’s a collision in the dataview formatter preventing this.

Things I have tried

This works, except for the noted issue

table without ID
	link(file.link, title) as "Event", startTime as "Time"
from "Calendar"
where 
	(type = "recurring" and contains(daysOfWeek, dateformat(date(today), "EEEEE")))
or
	date = date(today)
sort startTime ASC

dateformat(date(today), "EEEEE")
seems to return “T” for both Tuesday and Thursday, which is NOT how FullCalendar (or, any other source I’ve used) records things.

What I’ve not been able to do is find a way to recreate this, but forcing it to look for “R” on Thursdays.

When trying a few dataviewjs approaches, I think I’m running into the differences in metadata stored for individual events (they have a date field, but not type) and recurring events (they have a type field, but not date), and so all of the queries I’ve tried seem to choke when it’s searching for the value of a non-existent field.

I’m not married to any specific approach, what I want is a listing of the events for today, both things explicitly scheduled and things that recur today.

Any help anyone could provide would be much appreciated

Forgetting the Full Calendar plugin part (I never tried and I don’t know how it works), you want to see a table with recurrent things per day-of-the-week, right?
Ignoring the daysOfWeek field, each file have a date? What’s is the date field`?
I ask this because if you have a valid date you can extract the day of the week from each date and compare with the day of the week of the today date.

Sort of. I want both “things I scheduled explicitly for today” and “the things I have that recur today”

No, that’s the problem. They either have a date field (for things scheduled once) or they have a daysOfWeek field for which days the occur.

I think the issue is, when writing something like this (I’ve tried lots of iterations, and they all fail in different ways)

var dateformat = "YYYY-MM-DD";
if (dv.current().dateformat) { dateformat = dv.current().dateformat; }
const eventsFolderPath = "Calendar";
dv.list(
	dv.pages(`"${eventsFolderPath}"`)
	.where( p.file.day.equals(dv.current().file.day) || p.daysOfWeek.contains(dateformat(date(today), "EEEEE")))
);
dv.table(["File"], 
	dv.pages(`"${eventsFolderPath}"`)
	.map(p =>[p.file.link]
));

The line .where( p.file.day.equals(dv.current().file.day) || p.daysOfWeek.contains(dateformat(date(today), "EEEEE"))) seems to choke because no file has both of these.

The “EEEEE” format is “single letter day of the week”, and it seems to collide “T” for both “Tuesday” and “Thursday”, which is what got me here in the first place.

Ignoring the JS part (I’m not versed in JS…), in some way you need to re-write the single localized letter. For example, you can use EEE format to write the desired single letter.

TABLE
    link(file.link, title) as "Event", startTime as "Time"
FROM "Calendar"
FLATTEN dateformat(date(today), "EEE") AS wDay
FLATTEN ((x) => { Mon: "M", Tue: "T", Wed: "W", Thu: "R", Fri: "F", Sat: "S" , Sun: "U" }[x])(wDay) AS sDay
WHERE daysOfWeek = sDay

(I’m not sure about the localized format: Mon, Tue, Wed… It’s not my localized format :slight_smile: )

This is very close to what I need. But, some of my events recurr on multiple days, so I need

where contains(daysOfWeek, sDay)

but it seems like that’s not correctly interpreting `sDay’ as a variable. When I (as a test) put in a specific letter code, it works as expected, but not when I use the block I wrote above.

Searching didn’t yield any results on how to make contains() treat the second argument as a variable it needed to reference.

Any insights?

If also multiple letters code in daysOfWeek, then you need to use WHERE contains(daysOfWeek, sDay).
But, maybe you have a problem with the way you write your values: are they really a list/array? What’s the used syntax?

What “block”?

Don’t forget one thing: after “FROM” the order of the commands matters…

Yes, that’s it exactly.

This is an example of an entry that recurs on multiple days: daysOfWeek: [F,M]

vs one that is just a single day:
daysOfWeek: [R].

So, that looks like a list, in either case.

I’d mean the example I’d written of
where contains(daysOfWeek, sDay)

That’s exactly what I currently have, but its not currently working as expected.

What it looks like its doing is referencing the whole flattened map sDay vs it giving a specific value.

Rather than talking around it, here’s the whole block.

table without ID
	link(file.link, title) as "Event", startTime as "Start", endTime as "End"
from "Calendar"
FLATTEN dateformat(date(this.file.date), "EEE") AS wDay
FLATTEN ((x) => { Mon: "M", Tue: "T", Wed: "W", Thu: "R", Fri: "F", Sat: "S" , Sun: "U" }[x])(wDay) AS sDay
where 
	contains(daysOfWeek, sDay)
or
	date = date(this.file.date)
sort startTime ASC

What I expect is a list of all events that either happen today (date) or list today as one of its recurrences.

What I get is the list of today’s events and everything that has any recurrence.

What’s this.file.date?

It’s related with a custom field named date? If yes, you can’t add the prefix file, because that is in at page level, not at file level.
Use instead this.date.
(one suggestion: avoid to use fields key with the same name of functions.)

If the title of your file have the format YYYY-MM-DD then you can use the implicit field file.day.

Updating references to use file.day did not change the outcomes at all. But, I appreciate you pointing out a more correct way to do this.

I’m still getting my head around all of this.

To debug better your use case, if you’re interested send 2 or 3 example files.


One example with test files in my vault (sorry, it’s in portuguese):

Thank you. After stepping away and looking at your example, I figured out what I was doing wrong.

The second half of the where clause needed to be file.day = this.file.day (checking if the day attached to the calendar entry matched the day of today’s file)

For anyone intersted in the future, here’s what I came up with:

table without ID
	link(file.link, title) as "Event",
	startTime as "Start", 
	endTime as "End"
from "Calendar"
FLATTEN dateformat(date(this.file.day), "EEE") AS wDay
FLATTEN ((x) => { Mon: "M", Tue: "T", Wed: "W", Thu: "R", Fri: "F", Sat: "S" , Sun: "U" }[x])(wDay) AS sDay
where 
	contains(daysOfWeek, sDay)
	or
	file.day = this.file.day
sort startTime ASC

Thank you for your help getting to the bottom of this!

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