Easiest way to implement "days since" or "days till" counters?

The solution also depends if this is an isolated need or if it’s a more structured request with implications in the way you compose your notes.
Let’s try the second case (a more ‘structured’ way).
Let’s say you have a note for your “December vacations” and other for your friend “John birthday”.
In these notes you need to create a field with the date. For dataview plugin you can create this field in two ways: in yaml frontmatter with the syntax key: value; or an inline-field with the syntax key:: value. (here I’ll use the second type of field - inline field)

December vacations

# December vacations

duedate:: 2021-12-20

---

This is my note about my next vacations in December.

John birthday

# John birthday

duedate:: 2022-01-15

---

This is my note about the next John birthday

Now, you can work with this data field in multiple ways.


Case 1

You want a main note with the “countdown” for important events. In particular, you want a list/table with a panoramic view to all the next ‘big’ dates.
You can create this query:

## Next events

```dataview
TABLE duedate, duedate - date(today) AS "Remaining days"
WHERE duedate AND duedate >= date(today)
```

This is the result (ignore the date format - it’s my os language):


Case 2

You want write a note with the dynamic value somewhere in your text… Something like:

«I need to buy train tickets because I only have x days for the december vacations.»

In this case you want the “x days” as dynamic value. For this you can write this:

I need to buy train tickets because I only have `=[[December vacations]].duedate - date(today)` for the december vacations.

The result:


14 Likes