Date Comparisons Not Behaving As Expected For GT, LT, or EQ - using string objects as well as date objects as well as striptime
See original GitHub issueWhat happened?
I am trying to compare dates, and none of my queries are working as expected. I want to compare “due” to “date(today)” in which “due” is a field I have set in a file.
DQL
due:: July 25 2022
Now, check what today
and this.due
return:
= date(today)
= this.due
Now, attempt to compare them:
Inline DQL Query | Expected | Actual |
---|---|---|
= this.due >= date(today) |
True | True |
= date(today) <= this.due |
True | True |
= date(today) >= this.due |
True | False |
= this.due <= date(today) |
True | False |
= date(today) = this.due |
True | False |
= this.due = date(today) |
True | False |
= this.due > date(today) |
False | True |
= date(today) > this.due |
False | False |
= this.due < date(today) |
False | False |
= date(today) < this.due |
False | True |
And then, using striptime()
because many suggestion on GitHub point to this function:
Inline DQL Query | Expected | Actual |
---|---|---|
= striptime(date(this.due)) >= date(today) |
True | False |
JS
No response
Dataview Version
0.5.41
Obsidian Version
0.15.8
OS
MacOS
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
Comparing dates isn't working as expected - Stack Overflow
I just want to check if the date of today is greater than or equal to the expiringdate. But I can't figure it...
Read more >datetime — Basic date and time types — Python 3.11.1 ...
Date and time objects may be categorized as “aware” or “naive” depending on whether or not they include timezone information. With sufficient knowledge...
Read more >cpython/datetime.py at main - GitHub
Utility functions, adapted from Python's Demo/classes/Dates.py, which ... """Represent the difference between two datetime objects. Supported operators:.
Read more >as.POSIXlt: Date-time Conversion Functions - Rdrr.io
Date -time Conversion Functions. Description. Functions to manipulate objects of classes "POSIXlt" and "POSIXct" representing calendar dates and times.
Read more >Using Python datetime to Work With Dates and Times - ceaksan
Predefined Python datetime module, we can practically convert date and time data from character string to time-date object and perform various operations.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re using a no recognized date format. You can’t use
due:: July 25 2022
. You need to use ISO format, i.e.,due:: 2022-07-25
. https://blacksmithgu.github.io/obsidian-dataview/data-annotation/#field-types In the format it is, it’s a simple string.Yes, but there’s a big difference between the format to input data (in case the format to be recognized as date) and the output format (the format you can define as default in settings or for specific case using the function
dateformat()
). 😄 @AB1908 will close this “bug” report.