Count the number of modified notes of today, excluded the new notes of today

I use the following code in my daily notes for the number of new notes and the number of modified notes, based on this topic, which just closed:

New: $= dv.pages().where(t => t.file.cday.ts == dv.current().file.day.ts).length
Modified:$= dv.pages().where(t => t.file.mday.ts == dv.current().file.day.ts).length

The number of modified notes also includes the number of created files I would like to display the number of modified notes, but without the number of new notes of that day.
The result for the above line is for example: New: 13 and Modified: 63. I would like the modified number to show 50 (63 -/- 13).

I thought I could solve it with this code:

$= dv.pages().where(t => t.file.mday.ts == dv.current().file.day.ts && !t.file.cday == dv.current().file.day.ts).length

But this does not solve my problem, because the result is “0”, which i don’t understand.
When I remove the “!” before the second part of, I get the result of 12. I think this is the result of all the new notes, without the daily-note of that day. I have searched this forum and more sites for better understanding off the code en tried multiple variations, but I couldn’t get it right.

It looks like that’s returning 0 because t.file.cday is a truthy value, which means !t.file.cday is coerced to false. There will be no documents where false == dv.current().file.day.ts, so length is 0.

I believe a slight modification to your code will give you the number of files that were modified today but created on a previous day (though I just lifted your code and haven’t tested it in Obsidian to confirm):

`$= dv.pages().where(t => t.file.mday.ts == dv.current().file.day.ts && t.file.cday.ts != dv.current().file.day.ts).length`
1 Like

Thanks @geoffb, that was the solution I needed! The new part of my daily notes, with your code, is now as follows:

[!data]- New Today: $= dv.pages().where(t => t.file.cday.ts == dv.current().file.day.ts).length. Modified today: $= dv.pages().where(t => t.file.mday.ts == dv.current().file.day.ts && t.file.cday.ts != dv.current().file.day.ts).length

[!col]

list 
WHERE file.cday = date("2023-02-03")
SORT file.ctime DESC
list 
WHERE file.mday = date("2023-02-03")
WHERE file.cday != date("2023-02-03")
SORT file.mtime DESC

I use the outcome as an part of the header of the callout.
With the plugin “Obsidian columns” I created 2 columns with each a dataview-query. The numbers in the header are the same amount as the number of items on the list.

1 Like

Please enclose examples with markdown and code blocks with at least four backticks before and after to ensure proper formatting.

I am sorry, I thought I had done it properly, but apparently not. See below:

>[!data]- Today new: **`$= dv.pages().where(t => t.file.cday.ts == dv.current().file.day.ts).length`** â‹® Today modified: **`$= dv.pages().where(t => t.file.mday.ts == dv.current().file.day.ts && t.file.cday.ts != dv.current().file.day.ts).length`**
>> [!col] 
>>
>>```dataview
>> list 
>> WHERE file.cday = date("2023-02-04")
>> SORT file.ctime DESC
>>```
>>
>> ```dataview
>> list 
>> WHERE file.mday = date("2023-02-04")
>> WHERE file.cday != date("2023-02-04")
>> SORT file.mtime DESC
>>```

In my template I use the “standard”-code of Templater to add the date of that daily note.

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