Dataview table exists since field error

What I’m trying to do

I have created an exists since field on my notes

existsSince::= (date(today) - date(this.file.cday)).days

This is helpful as I can see the number of days it has been since a note has been created

I want to pull through this field information into a dataview table - currently it looks like

TABLE WITHOUT ID
link(file.path, string(description)) AS "Task", dateformat(file.ctime, " HH:mm") AS "Time Created" , existsSince

FROM #task AND -"3. Templates"

WHERE 

file.cday = this.file.cday OR file.cday = date(yesterday)

SORT Priority ASC

So basically I only want to see the notes from today or yesterday - however, when for some unknown reason even though the existsSince field works correctly e.g it says ‘1’ if it has been one day since it has been made - it still displays a ‘0’ on the table view…

Any help much appreciated!

Things I have tried

asked the forum


Here you are storing the query itself, and not the result of the query. So when referring to this field elsewhere the query can be/ is executed in that context. In most cases this yields the wrong result.

You need to repeat the calculation from above into the other query in order to correctly see the age of the task.

Check the difference (or rather the resemblance) of the following (when going to reading view) :

aField:: 42
aQuery:: `= (date(today) - this.file.cday).days`

Value of aField: `$= dv.paragraph("~~~\n" +dv.current().aField + "\n~~~\n")`
Value of aQuery: `$= dv.paragraph("~~~\n" +dv.current().aQuery + "\n~~~\n")`

Thank for quick response! - so do I put the text you shared on the specific note?

aField::

aQuery:: = (date(today) - date(this.file.cday)).days

Value of aQuery: $= dv.paragraph("~~~\n" +dv.current().aQuery + "\n~~~\n")

Value of aField: $= dv.paragraph("~~~\n" +dv.current().aField + "\n~~~\n")


And then leave this original one I shared as is?

TABLE WITHOUT ID
link(file.path, string(description)) AS “Task”, dateformat(file.ctime, " HH:mm") AS “Time Created” , existsSince

FROM #task AND -“3. Templates”

WHERE

file.cday = this.file.cday OR file.cday = date(yesterday)

SORT Priority ASC

The code example I provided was to showcase how your definition actually works to store the query itself, and not the result of the query. It could be inserted (and/or removed) whereever you want it.

In the end of the day you need to modify your query to do the calculation of the days it has existed within that query. It can’t be precalculated, and reused in another query.

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