Weekly notes review – show specific notes only

What I’m trying to do

i’m creating a note template for weekly notes where i want to list the books and articles i read in said week.

Things I have tried

first, i tried to get this information by way of using the creation date of my literature note. this worked just fine:

```dataview
LIST
WHERE econtains(type, "literature")
WHERE date(file.cdate).year = date(this.file.cday).year
WHERE date(file.cdate).weekyear = date(this.file.cday).weekyear
```

but there’s a missmatch of the creation date of the note and the day i read the book/article, therefore i added another parameter to the front matter:


reading-date: 30-08-2022

now, i don’t now how to make the dataview search work with this adaption. that’s why i’m reaching out to the community. may i ask you to be patient as i’m new to obsidian and not familiar with JS.

Topic

Summary
  • How to transform the value of the reading-date field into the format like yyyy-MM-dd?
  • How to design a weekly note?
    • DQL10_Q1 : via this.file.cday (PS. I have never created the weekly notes later.)
    • DQL10_Q2 : via this.startDateOfWeek like “2022-09-19”
    • DQL10_Q3 : via this.yyyy_WW like “2022W38”
    • DQL10_Q4 : via this.file.name like “2022W38”

Test

Summary
  • dataview: v0.5.46

Input

Summary

the current weekly note

  • filename : 2022W38 // DQL10_Q4 used
  • this.file.cday = date(“2022-09-21”) // DQL10_Q1 used
  • The YAML field startDateOfWeek(or endDateOfWeek) is used by the DQL10_Q2.
  • The YAML field yyyy_WW is used by the DQL10_Q3.
---
yyyy_WW : 2022_38
startDateOfWeek : 2022-09-19
endDateOfWeek   : 2022-09-25
---

### DQL10



dictionary files

  • Location: “100_Project/02_dataview/Q15_Reading/Q15_test_data”

folder: 03

  • filename : dic_19960301
---
Date: 1996-03-01
type: literature
reading-date: 31-03-2022
date_format : dd-MM-yyyy
---



folder: 04

  • filename : dic_19960401
---
Date: 1996-04-01
type: literature
reading-date: 20-09-2022
date_format : dd-MM-yyyy
---



folder: 05

  • filename : dic_19960501
---
Date: 1996-05-01
type: literature
reading-date: 21-09-2022
date_format : dd-MM-yyyy
---



folder: 08_wrong_month

  • filename : dic_19960801
---
Date: 1996-08-01
type: literature
reading-date: 30-76-2022
date_format : dd-MM-yyyy
---



DQL10_transform_reading-date_into_yyyy-MM-dd

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL10_transform_reading-date_into_yyyy-MM-dd reading-date:
a string like dd-MM-yyyy
no 1.To filter by reading-date
2.To define a field variable s_rDate by using FLATTEN
3.To transform the value of reading-date into yyyy-MM-dd
4.To filter by date(s_rDate)
5.To display the result as a table
ONLY for reading-date field where the value is like dd-MM-yyyy

Notes

Summary

Q1: What is the same code to get the daily notes for a specific week compared with this.file.cday? (PS. I always create weekly notes on time.)

Summary_Q1
Original Example10
```dataview
WHERE date(s_rDate) != null
WHERE date(s_rDate).year = this.file.cday.year
WHERE date(s_rDate).weekyear = this.file.cday.weekyear
```

A1:

Another Example11
  • WW: ISO week number, padded to 2
```dataview
WHERE date(s_rDate) != null
WHERE dateformat(date(s_rDate), "yyyy_WW") = dateformat(this.file.cday , "yyyy_WW")
```

Q2: How to modify the following code to get the daily notes for a specific week compared with this.startDateOfWeek like “2022-09-19”? (PS. Sometimes I create the weekly notes later.)

Summary_Q2
Original Example20: To be modified
  • filename : 2022W38 // the current weekly note
---
startDateOfWeek : 2022-09-19
endDateOfWeek   : 2022-09-25
---
```dataview
WHERE date(s_rDate) != null
WHERE dateformat(date(s_rDate), "yyyy_WW") = dateformat(this.file.cday , "yyyy_WW")
```

A2:

Another Example21
```dataview
WHERE date(s_rDate) != null
WHERE dateformat(date(s_rDate), "yyyy_WW") = dateformat(this.startDateOfWeek , "yyyy_WW")
```

OR

```dataview
WHERE date(s_rDate) != null
WHERE dateformat(date(s_rDate), "yyyy_WW") = dateformat(this.endDateOfWeek , "yyyy_WW")
```

Q3: How to modify the following code to get the daily notes for a specific week compared with this.yyyy_WW like “2022_38”? (PS. Sometimes I create the weekly notes later.)

Summary_Q3
Original Example30: To be modified
  • filename : 2022W38 // the current weekly note
---
yyyy_WW : 2022_38
---
```dataview
WHERE date(s_rDate) != null
WHERE dateformat(date(s_rDate), "yyyy_WW") = dateformat(this.file.cday , "yyyy_WW")
```

A3:

Another Example31
```dataview
WHERE date(s_rDate) != null
WHERE dateformat(date(s_rDate), "yyyy_WW") = this.yyyy_WW
```

Q4: How to modify the following code to get the daily notes for a specific week compared with this.file.name like “2022W38”? (PS. Sometimes I create the weekly notes later.)

Summary_Q4
Original Example40: To be modified
  • filename : 2022W38 // the current weekly note
```dataview
WHERE date(s_rDate) != null
WHERE date(s_rDate).year = this.file.cday.year
WHERE date(s_rDate).weekyear = this.file.cday.weekyear
```

A4:

Another Example41
```dataview
WHERE date(s_rDate) != null
WHERE dateformat(date(s_rDate), "yyyy_WW") = replace(this.file.name, "W", "_")
```

OR

```dataview
WHERE date(s_rDate) != null
WHERE date(s_rDate).year = number(split(this.file.name, "W")[0])
WHERE date(s_rDate).weekyear = number(split(this.file.name, "W")[1])
```

Code DQL10_transform_reading-date_into_yyyy-MM-dd

Summary_code
title: DQL10_transform_reading-date_into_yyyy-MM-dd =>ONLY for `reading-date` field where the value is like dd-MM-yyyy 1.To filter by `reading-date` 2.To define a field variable `s_rDate` by using `FLATTEN` 3.To transform the value of `reading-date` into yyyy-MM-dd 4.To filter by `date(s_rDate)` 5.To display the result as a table
collapse: close
icon: 
color: 
```dataview
TABLE WITHOUT ID
      file.link AS "File",
      s_rDate AS "s_rDate",
      date(this.file.cday).weekyear AS "this_weekyear",
      date(s_rDate).weekyear AS "weekyear"

FROM "100_Project/02_dataview/Q15_Reading/Q15_test_data"
WHERE econtains(type, "literature")
WHERE reading-date != null

FLATTEN regexreplace(reading-date, "^(\d{2})-(\d{2})-(\d{4})$", "$3-$2-$1") AS s_rDate

WHERE date(s_rDate) != null
WHERE date(s_rDate).year = this.file.cday.year
WHERE date(s_rDate).weekyear = this.file.cday.weekyear

```

Screenshots(DQL10)


Reference

Summary

Q88_Links: Regular Expressions

luxon Formatting


great, this helps!
i further adapted the code so that the weekyear is not extracted from the creation date, but from the file name because sometimes i create the weekly notes later.

my version is this:

```dataview
LIST
FROM "3_knowledge-base"
WHERE econtains(type, "literature")
WHERE reading-date != null
FLATTEN regexreplace(reading-date, "^(\d{2})-(\d{2})-(\d{4})$", "$3-$2-$1") AS s_rDate
WHERE date(s_rDate) != null
WHERE date(s_rDate).year = this.file.cday.year
WHERE date(s_rDate).weekyear = number(split(this.file.name, "W")[1])
```

this works perfectly!

i also tried to use the same method for extracting the year from the filename, but for some reason this didn’t work. (run by itself it returns “2022” as the above function. any idea why id doesn’t work when implemented in the dataview code?

```dataview
WHERE date(s_rDate).year = number(split(this.file.name, "-",1))
```
1 Like

Inline DQL exercises:

Summary
```md
aResult11 = `=split("2022-09-19", "-",1)`//=>2022

sResult13 = `=typeof(split("2022-09-19", "-",1))`//=>array

nResult21 = `=number(split("2022-09-19", "-",1)[0])`//=>2022

sResult23 = `=typeof(number(split("2022-09-19", "-",1)[0]))`//=>number
```

To modify:

Summary

Wrong example:

```dataview
WHERE date(s_rDate).year = number(split(this.file.name, "-",1))
```

Correct example:

```dataview
WHERE date(s_rDate).year = number(split(this.file.name, "-",1)[0])
```

OR

```dataview
WHERE date(s_rDate).year = number(split(this.file.name, "-")[0])
```

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