blacksmithgu / obsidian-dataview

A data index and query language over Markdown files, for https://obsidian.md/.
https://blacksmithgu.github.io/obsidian-dataview/
MIT License
7.06k stars 415 forks source link

Bug report #2437

Open irodionzaytsev opened 2 months ago

irodionzaytsev commented 2 months ago

What happened?

DateTime documentation - I cannot convert it to string and compare to today. In debugger console I understand that I have a DateTime variable, but I cannot find its documentation and understand how to exctract the date from it (i want to display tasks completed today. I can't convert them to ISO string.

DQL

// Get today's date in the format YYYY-MM-DD
const today = new Date().toISOString().split("T")[0];
// Initialize a counter for tasks completed today
let completedTaskCount = 0;

// Loop through all tasks in your vault
dv.pages().file.tasks.where(t => 
t.completed)
.forEach(t => {completedTaskCount++;
    console.log(t.completion.toISOString());});

// Output the count of tasks completed today
dv.paragraph(`**Tasks completed today:** ${completedTaskCount}`);

JS

No response

Dataview Version

latest

Obsidian Version

latest

OS

Linux