Skip to content

Instantly share code, notes, and snippets.

@therealfakemoot
Last active September 14, 2022 23:45
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save therealfakemoot/5d40568631136c12fb63440ddde11677 to your computer and use it in GitHub Desktop.
Save therealfakemoot/5d40568631136c12fb63440ddde11677 to your computer and use it in GitHub Desktop.

<< [[2022/05/2022-05-17]] | [[2022/05/2022-05-19]] >>

Wednesday, May 18, 2022

[!tldr]- This day last year ![[2021/05/2021-05-18]]

[!tldr]- Created

dv.view("meta/views/same-day-notes", {"filter":"created"})

[!tldr]- Modified

dv.view("meta/views/same-day-notes", {"filter":"modified"})
const refday = dv.current().file.cday.toISODate()
// this creates two anonymous functions that return true if a given note's modification or creation time match refday ( today ), respectively
// ultimately, these get used as arguments to a where() call
mtime = (p => p.file.mday.toISODate() === refday)
ctime = (p => p.file.cday.toISODate() === refday)
let q
// This is for debugging, or when you arne't executing this via dv.view()
// let input={filter:"modified"}
switch (input.filter) {
case "modified":
q = mtime
break
case "created":
q = ctime
break
}
dv.table(
["Note", "Summary"],
dv.pages("").where(q).where(f => !f.file.path.startsWith("meta/")).map( function(b) {
// this is where i use aliases instead of filenames if possible
name = b.file.name;
if (b.file.aliases.length != 0) {
name = b.aliases[0]
}
return [dv.fileLink(b.file.path,false,name), b.summary]
})
)
@DeutscheGabanna
Copy link

I get this error when using your snippet:
Evaluation Error: ReferenceError: mtime is not defined at eval (eval at <anonymous> (eval at <anonymous> (app://obsidian.md/app.js:1:1494667)), <anonymous>:3:7) at DataviewInlineApi.eval (eval at <anonymous> (app://obsidian.md/app.js:1:1494667), <anonymous>:19567:16) at evalInContext (eval at <anonymous> (app://obsidian.md/app.js:1:1494667), <anonymous>:19568:7) at asyncEvalInContext (eval at <anonymous> (app://obsidian.md/app.js:1:1494667), <anonymous>:19578:32) at DataviewJSRenderer.render (eval at <anonymous> (app://obsidian.md/app.js:1:1494667), <anonymous>:19606:19) at DataviewJSRenderer.onload (eval at <anonymous> (app://obsidian.md/app.js:1:1494667), <anonymous>:19198:14) at DataviewJSRenderer.e.load (app://obsidian.md/app.js:1:676468) at t.e.addChild (app://obsidian.md/app.js:1:676892) at Object.addChild (app://obsidian.md/app.js:1:1561486) at DataviewPlugin.dataviewjs (eval at <anonymous> (app://obsidian.md/app.js:1:1494667), <anonymous>:19766:19)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment