This week's meetings only from the current year - dataviewJS

What I’m trying to do

I am trying to show all notes with a certain tag (meeting) in my weekly review note. The following code does this but it shows meetings from both the current year and previous years. I would like it to show just the current year.

Frontmatter:

---
date: 2023-08-02
date modified: 2023-08-03
tags:
  - weekly
---

Dataview code:

dataviewjs
let currentWeekNumber = dv.current().date?.weekNumber;
dv.list(dv
	.pages("#meeting")
	.where(n => n.date?.weekNumber == currentWeekNumber)
	.sort(n => n.date)
	.file.link)

Here is the output:
Untitled

Things I have tried

I used advice from

and here:

I found this but I’m in over my head with Dataview JS and not sure what to do next:

Thank you for any help you can provide or if you have a simpler way to do this, pleas elet me know.

Henry

My friend ChatGPT says:
The issue in the code is that it’s filtering by the current week number, but not taking the year into account. Week numbers restart each year, so without considering the year, you may get results from the same week number but from different years.
Here’s a corrected version of the code that filters by both the current week number and the current year:

```dataviewjs
let currentDate = dv.current().date;
let currentWeekNumber = currentDate?.weekNumber;
let currentYear = currentDate?.year;
dv.list(dv
	.pages("#meeting")
	.where(n => n.date?.weekNumber == currentWeekNumber && n.date?.year == currentYear)
	.sort(n => n.date)
	.file.link)

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