Hello, sorry but the problem presented again… Here’s my snippet:
TABLE WITHOUT ID "Day "+ string((date(file.cday) - date(2023-01-09)).days+1) AS "Day",link(file.link) as "Note" ,MMs AS "Goal", MM as "Recap"
FROM "2 - Journaling/Daily Notes"
WHERE MM and ((date(file.cday) - date(2023-01-09)).days)+1 <= 30
SORT file.ctime asc
Basically I want to be listed only day 1 to 30, as you can see day 29 is not being plotted:
If I change the snippet in:
WHERE MM and ((date(file.cday) - date(2023-01-09)).days)+1 <= 35
I get this
That’s of course completely wrong… Someone can help me solving this? Thank’s
I really don’t know for sure, but in my local tests (with ISO dates used as file names in my journal), file.cday gives imperfect results as not all the files were created on the dates they refer to. I get accurate results if I use file.day. It’s not clear to me if this is the issue you are facing, but thought I’d mention it just in case it is at all relevant … though your files don’t appear to be in ISO (YYYY-MM-DD) format, so probably spurious.
```dataview
TABLE WITHOUT ID
"Day "+ string((date(file.day) - date(2023-01-09)).days+1) AS Day,
link(file.link) as Note
FROM
"journal/2023"
SORT
file.name ASC
LIMIT
10
```
At least my rambling post helps to bump the thread.
I’m sorry to bother people but I really tried searching everywhere on the forum and on documentation, this is driving me crazy. Is really anyone there able to solve this easy issue?
Also, the problem persist if I try to use dataview inline: =( date(2023-02-05) - date(2023-01-09)).days result in 27 =( date(2023-02-06) - date(2023-01-09)).days result in 30
As you’ve most likely understood by now, there is a an issue when the duration extends beyond a month, and then it becomes buggy. One way around this, is to convert everything to a unix timestamps in seconds, and do a little bit of math.
```dataview
TABLE WITHOUT ID
dateformat(date(cday), "X"),
dateformat(date(2023-01-09), "X"),
(date(cday) - date(2023-01-09) ).days as OrgDays,
dayCount
FLATTEN list("2023-02-03", "2023-02-04", "2023-02-05", "2023-02-06") as cday
FLATTEN
((number(dateformat(date(cday), "X")) -
number(dateformat(date(2023-01-09), "X")) ) / 86400) as dayCount
WHERE file.name = this.file.name
```
The main thingy here is the last FLATTEN:
number( ... ) – Pulls out a number from a string
dateformat( ..., "X" ) – Format the date as a unix timestamp in seconds (aka seconds since 1970 or something like that)
Subtract these two values, and divide by 86400 which is the number of seconds in one day, and we get the dayCount between the two days
The other stuff in my query, is just to illustrate and test out the query. You’ll need to put back in file.cday instead of my cday (which I generated from a list), and adapt everything else to your situation. The key component though, is that last FLATTEN, which should be copy-paste (with the cday change), and then you can use dayCount in other parts of your query.