I made a where statement that should equal, but it doesn't

As the title says; I did write a where statement in dataview to shows an appointment when it’s set day to be today and date is also to be today. The day checks and work if appointment is set on Monday is shows all Monday’s appointment. And date it, so makes sure to show this Monday’s

Things I have tried

The code I am using

dv.header(2, "[[Week Board|Today Schedule]]")
var date = new Date();
const week = ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'];
var currentDate = dv.date(new Date().toJSON().slice(0, 10));

dv.table(["Termin", "Priority", "Starts", "Ends", "Date"], dv.pages("#Termin").sort(p => p.startTime, "ASC").where(b => b.Day === week[date.getDay()]).where(b => b.date === currentDate).map(b => [b.title, b.Priority, b.startTime, b.endTime, b.date]));

MetaData from an appointment note.
2022-09-16_17-25

What I’m trying to do

Equal today’s date with date from a note. I made sure to convert currentDate into Date datatype to match one from note.
You can see here that b.date datatype is date same as the one from Metadata
2022-09-16_17-27

Hi. I’m a really noob in JS, I only know some dvjs commands/functions.
If JS is an unknown field, well, dates in JS are a terrible thing.
Because dataview works with luxon format, I suggest some “forced” conversions to iso to make the wanted comparisons.
So, try this:

dv.header(2, "[[Week Board|Today Schedule]]")

var date = dv.date('today');
const week = ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'];
var currentDate = dv.date(new Date().toJSON().slice(0, 10));

dv.table(["Termin", "Priority", "Starts", "Ends", "Date"],
	dv.pages("#Termin").sort(p => p.startTime, "ASC")
	.where(b => b.Day === week[date.weekday])
	.where(b => b.date.toISODate() === currentDate.toISODate())
	.map(b => [b.title, b.Priority, b.startTime, b.endTime, b.date])
);
1 Like

Thanks it worked :smiley:

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