Days operator issue

Hello!
Please see the screenshot attached:

.

On the default tiddlywiki file (tiddlywiki.com) I created tiddlers with titles reflecting content of their “date” field and contents of their “timespan” field.
“date” field contains date at midnight e.g. 20251029000000000 (note: in the screenshot I missed two zeroes when writing the example but the actual fields are correct nonetheless).
“timespan” field contains negative integer.

Using a nested list I am trying to display tiddlers with date field being x or more days in the past (indicated by the negative integer in “timespan” field).
Dates that are 1-3 days in the past work as expected but 4 or more days in the pasts seem to pass the filter one day too early.

The list looks like this:
<$list filter="[has[date]]">
<$list filter="[all[current]!days:date{!!timespan}]">
<$link/>

</$list>
</$list>

Am I just confused about the usage of days operator or is this a bug/inconsistency? It seems weirdly arbitrary how the expected behaviour breaks after -3.

Hello @uusminuus ,
A previous post by @Mohammad may help your understanding of the Days Operator.
Today, Yesterday and Tomorrow with Days Filter Operator
The post has an example and demo json tiddlers.

Hello, thank you for your answer!
I read the thread you linked and the official documentation.
I still do not understand what leads to the behavior in my screenshot:
Today is 29.10.2025.
A tiddler with date=20251027000000000 (2 days ago) is filtered out (as expected) with [!days:date[-3]].
A tiddler with date=20251026000000000 (3 days ago) is NOT filtered out with
[!days:date[-4]].

Notice how the list does not change between [!days:date[-4]] and [!days:date[-3]].
I would expect the [!days:date[-5]] be empty and [!days:date[-4]] contain only one item.

1 Like

I am not sure but I think the number of 0’s in the date format are wrong.
Try these tiddlers and let me know if they work
Three Days Before.json (172 Bytes)
Four days before.json (171 Bytes)
Five Days before.json (171 Bytes)


The same problem persists.

There are 9 zeroes after the date (hhmmssXXX)

Maybe @Mohammad can help

Example

\define mytasks(filter, label)
<table>
<tr><th colspan=3>$label$</th></tr>
<$list filter=<<__filter__>> >
<tr>
<td><$link/> </td><td> <$text text={{!!due}}/></td>
<td><$view field=due format=date template="0DDth, MMM, YYYY"/></td>
</tr>
</$list>
</table>
\end

<<mytasks filter:"[tag[Task]!tag[Done]sort[due]]" label:"All Tasks">>
<<mytasks filter:"[tag[Task]!tag[Done]days:due[0]]" label:"Today">>
<<mytasks filter:"[tag[Task]!tag[Done]days:due[-1]!days:due[-1]]" label:"Yesterday">>
<<mytasks filter:"[tag[Task]!tag[Done]days:due[1]!days:due[1]]" label:"Tomorrow">>

You may have to change your date field to due and change date format as the example ?

Download the json tiddlers and drag them on to Mehregan Edition or TiddlyWiki.com

today-yesterday-tomorrow-days-ops.json (2.9 KB)

1 Like

The example tiddlers only have 7 zeros after date
Eg
Five days before due: 202510240000000

The dates you are showing are UTC, not local. So to understand better what is going on, you would need to convert those dates to your local time.

Hi @uusminuus
I think the problem is the date format.
Your format is [UTC]
the format in the example was
<td><$view field=due format=date template="0DDth, MMM, YYYY"/></td>

Your format should be something like
<td><$view field=due format=date template="[UTC]DDth MMM YYYY" /></td>

Sorry @Mark_S
it took me so long to answer I hadn’t realised that you had already replied.
I’m unsure about the date field can you call it date or is this reserved in some way?

Hello, thank you for joining in helping.
My local time is UTC+2. I was not within 2 hours of midnight when noticing this problem. The problem happened when I used automatically saved timestamp in a field in UTC format. But I can’t resolve this by just changing the time part of the timestamp.
The problematic change in behaviour in my example screenshots happens when I change the timestamp by exactly one day and the parameter by exactly 1. The change in behavior happens when parameter goes from -3 to -4.
When parameter is -3, it does filter out a tiddler with timestamp that is 2 days ago (as I’d expect).
When parameter is -4, it does not filter out a tiddler with timestamp that is 3 days ago (why?)

I am so confused how does this arise.

Hello @uusminuus
I am afraid that you are not alone in finding this date formatting stuff confusing.
A general search on [UTC] shows this.

@EricShulman and @TW_Tones Converting a date from local time to UTC is the first of many.
They are more experienced in using TW than I and I am sure they will participate in this discussion before long.

1 Like

It would help if you could post your test tiddlers, or even your entire TW file (like at tiddlyhost.com) Otherwise we each have to hand-create the data, leading to more errors.

Good luck!

Filter.json (527 Bytes)
1 day ago.json (130 Bytes)
2 days ago.json (131 Bytes)
3 days ago.json (131 Bytes)
4 days ago.json (131 Bytes)
5 days ago.json (131 Bytes)

Notice how the number of listed items does not decrease by one when parameter goes from -3 to -4.

Note:The titles will be “outdated” soon since we are close to UTC date changing.

Here’s my version to display the dates.

\procedure dueit(offset)
filter=[!days:due[<<offset>>]]<br>
<$list filter="[!days:due<offset>]">
<$link/> | {{{[<currentTiddler>get[due]format:date[]] }}}<br>
</$list>
<p/>
\end


<$list filter="[range[-1,-5,-1]]" variable="offset">
<$macrocall $name=dueit offset=<<offset>> />

</$list>

What we need is a screenshot of what you see, plus the local time when you see it. And I know you may have to tweak your data now because time marches on. I had to reset all the data, picking a noon time just to make the math easier. Once I did that, everyone looked as expected.

Ha! This might be the most confusing week of the year to be comparing timestamps!

Interestingly, on the same machine, I get 2 different results on 2 different browsers:

  1. Firefox:

  2. Vivaldi:

Both run on linux, but I use Enhanced Privacy Settings on Firefox which set apparent time to UTC.

So I guess the problem is somewhat linked to local time conversion…

Fred

This! :laughing:

You made my day with this one!

“Ha! This might be the most confusing week of the year to be comparing timestamps!”

Wait. It is starting to make sense now.

26th october our local time moved 1 hour back when daylight saving time ended. That is the date where the one day offset happens.

Since the days filter does not seem to care about the time, only the date (making it effectively 00:00), I believe at some moment in the comparison the changing daylight saving time gives -1 hour, moving the date to previous one (before midnight).

Can’t quite wrap my head around how to fix it.

You can try 2 options:

  1. Use and store only UTC dates
  2. Store local dates with a timestamp of 120000000. This reduces the risk that a timezone offset will make a date cross the “day changing line”.

Fred

Try these new dated tiddlers and filter.
They work on TiddlyWiki.com

new-days-filter.json (1.8 KB)