New Bases: filter dates

When trying to dynamically filtering on a date. I found the following syntax in the inline base definition to work.

views:
  - type: table
    name: TODAY
    filters:
      and:
        - dateEquals(date(property.Review), date(now()))
    order:
      - file.name
      - Review
    columnSize:
      property.Review: 149
    sort:
      - column: file.name
        direction: ASC
      - column: property.Review
        direction: DESC

The trick was to convert the value from field (in the example “Review” which is a YAML date field) into a Date object first.

Hope this helps someone

5 Likes

Hey Armin, thank you for the tip.
I also tried this with dateOnOrBefore, but got this message:


Have you got a clue, how to solve this? I want to manage my tasks with this,
my goal is, to get a table with a weekly overview, one table with the tasks in the next week and one table with the tasks in the future, after next week…

yeah this is a Type issue you need to cut and paste the formular directly in (click on </>). the key is to convert both sides (left and right) using the date(…) function. This is the same whether you use the dateOnOrBefore or date equals etc function.. so
dateEquals(date(property.Review), date(now())) … for Todays notes
dateOnOrBefore (date(property.Review), date(now())) … for “overdue” notes

Ich benutze “Review” anstatt “FaelligkeitsDatum”
now() gives you Todays date

I have not yet explicit tried to add lets say 7 days dynamically. you may want to check out Javascript Luxon info that is what Obsidian is using.

What I do to have a table for tomorrow is using the review field in the document with the table it self so the formular becomes something like:

dateEquals(date(property.Review), date(this.property.Review))

so then I can just toggle the in note Review field (which is this.property.Review) and compare it to the Review field values in other notes.

Hope this helps

Thank you very much! Now its clearer for me…

Sebastian,

one more. I found in the documentation

dateModify()

  • dateModify(datetime, duration) retrieves a datetime modified by the provided duration.
  • duration may be a number of milliseconds (1 minute is equivalent to 60000)
  • duration may be a text value such as 2h, 2 hour, 2 hours, -2 hours
  • Valid units for duration text values are year, month, week, day, hour, minute, second, the plural versions, and the single letter abbreviation. month is abbreviated to M.

So this may be the ticket for your In 7 days feature.

Good luck

1 Like

But remember that the duration is a string, so needs double quoting (thanks to @dawni in another thread). Without the quotes dateModify usually returns the unmodified datetime value. I wasted 2 days trying to get this to work without the quotes :disappointed_face:.

date(dateModify(date(property.originalDateTime), "7 days")) should work.

3 Likes

and time flies - Version 1.9.2 changed all of the above. This is no longer valid.

see Bases syntax - Obsidian Help

so something as simple as Review == today() now works

Hey Armin,
I think the change was really positive,
I had to change all the tables again, but this was done within half an hour and everything is easier now. Thanks to the Obsidian team!