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”
- DQL10_Q1 : via
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
(orendDateOfWeek
) 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
```