Date Manipulation Problems

No, not looking for relationship advice! :slight_smile:

I’m new here and found SB a couple of weeks ago. I’m migrating from Logseq. Currently trying to recreate a task list with due/overdue items and ran into some date manipulation problems.

Here’s the markdown of the page:

Today is ${date.today()}

  • Really large project [taskdue: 2025-05-20]

Due Today and Overdue

${query[[from index.tag “task”
where ref:startsWith(“Problem”)
and taskdue<=date.today()
select {ref=ref,text=text,taskdue=taskdue}
]]}

Here’s what happens:

The task should not show up in the query results since it’s due tomorrow, and when the results are displayed in the table it changes the date to one day earlier. I’ve tested this with multiple dates and it’s always one day earlier in the table.

The timezone on the server is set correctly:

root@silverbullet:~/space# timedatectl
Local time: Mon 2025-05-19 10:17:38 EDT
Universal time: Mon 2025-05-19 14:17:38 UTC
RTC time: n/a
Time zone: America/Indiana/Indianapolis (EDT, -0400)
System clock synchronized: yes
NTP service: inactive
RTC in local TZ: no

Any ideas?

Must be some kind of black magic going on there xD
I can’t reproduce your issue, but I’ve still got some ideas that might help you narrow down the problem. Have you tried:

  • Putting quotes around the taskdue attribute value
  • Checking the attribute value outside of a query? i.e.
${index.getObjectByRef("Problem Example", "task", "Problem Example@29").taskdue}
  • Checking the type of the value returned by the statement above with ${type(...)}
  • Running a reindex (Space: Reindex)
  • and finally, reproducing your problem on a fresh sb instance?

I really can’t wrap my head around how the task attribute, with string type, is, during the query (or indexing), converted to a numeric date, then substracted by 1 day, and then converted back to a formatted date with string type ?!

Btw., not really related to your problem, but tasks automatically get the ‘deadline’ attribute indexed if you put 📅 <date> somewhere in the task text. Maybe looks a bit prettier that custom attribute definitions :smiley:

I think it’s a bug caused by a time zone issue. One of the tests in the code base has been failing for me consistently since I cloned the code, and I have been ignoring it. The test failure is this:

JSON utils => ./plug-api/lib/json.test.ts:4:6
error: AssertionError: Values are not equal.

    [Diff] Actual / Expected

-   2023-05-02
+   2023-05-03

I am in Eastern Time, so UTC-4 right now. Ultimately what is happening is a date object for midnight UTC is being converted to local time, which will result in the previous day for those of us before UTC.

I opened a PR.

2 Likes

I updated my docker container. I’m now running SilverBullet 2.0-beta (0.10.4-220-gf72e4bbf). I used quotes around the date and it now works. I did try that in the previous version and it didn’t work.

Sorry, I don’t have info about what version I was previously running.

Both of you: thanks for your help!

A fix for this date issue went into v2 yesterday. It looks like it’s fixed on my server when I query tasks with deadlines.

1 Like