Dataview strange date behavior in queries

Steps to reproduce

Use the following query
List FROM “” WHERE file.mday = date(“YYYY-MM-DD”) SORT file.mtime asc

Note: replace YYYY-MM-DD with real numbers such as 2023-02-24

Notice that the date is quoted inside the call to the date() function.

Expected result

What I expect to see is that the files which display in my Vault with = file.mday are used in the comparison.

Actual result

If the date is quoted, then the query appears to change the date of the file.mday factoring in the timezone. This causes files that were modified YESTERDAY to appear in TODAY’s search results.

In other words, Query Results suggest that if I edit a file AFTER GMT has crossed into the next day (I am -7 so anything after 5PM at night), then this file would appear as being edited the next day in the query results.

NOTE:
If I do not quote the date string & run the query as:

List FROM “” WHERE file.mday = date(YYYY-MM-DD) SORT file.mtime asc

Note the date is not quoted - then the query behaves as expected.

Environment

  • Operating system: MacOS / iOS / Windows
  • Debug info:
    SYSTEM INFO:
    Obsidian version: v1.1.9
    Installer version: v0.15.8
    Operating system: Darwin Kernel Version 22.2.0: Fri Nov 11 02:06:26 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8112 22.2.0
    Login status: logged in
    Catalyst license: supporter
    Insider build toggle: off
    Live preview: on
    Legacy editor: off
    Base theme: light
    Community theme: none
    Snippets enabled: 1
    Restricted mode: off
    Plugins installed: 14
    Plugins enabled: 13
    1: Calendar v1.5.10
    2: Natural Language Dates v0.6.1
    3: Note Refactor v1.7.1
    4: Pandoc Plugin v0.4.1
    5: Typewriter Scroll v0.2.2
    6: Advanced Tables v0.18.1
    7: Obsidian Charts v3.7.1
    8: Dataview v0.5.55
    9: Templater v1.16.0
    10: Heatmap Calendar v0.5.4
    11: Text Generator v0.1.22
    12: Better Word Count v0.9.4
    13: Style Settings v1.0.3

RECOMMENDATIONS:
Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets.
Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.


Additional information

The work around is simple, however, there were issues with dates in the 5.44 build, and I think this may be an obscure hangover from the addition of timezones to Dataview.

We do not take bug reports for community plugins on this forum, report this on the GitHub repository for the Dataview plugin.

My bad. Sorry. I’ll post it there.

I’m not sure if this is the case.
Maybe it is related with one day off in javascript.

Why the JavaScript date is one day off?

https://www.sunzala.com/why-the-javascript-date-is-one-day-off/

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