question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

What 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:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
mnvwvnmcommented, Jul 26, 2022

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.

0reactions
mnvwvnmcommented, Jul 26, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found