Bases - Filter books read in 2024

First of all I think Bases is a fantastic tool! I’m eager to test it on my mobile but on my PC is faster than Dataview in showing what I need.
The problem I’m facing is the following: I wish to check which books I’ve read in 2024.
With the help of this amazing community I’ve solved with dataview using this code:

```dataview
LIST
FROM "Libri"
WHERE date-start.year = 2024 OR date-read.year = 2025
SORT date-read ASC
How can I replicate the "WHERE" part in Bases?
My dates are in Italian format (dd/MM/yyyy) and Bases is asking me the date in this format.
I've already tried filtering with "on or after 01/01/2024" and "on or before 31/12/2024" (and also with "after 31/12/2023" and "on or before 01/01/2025) but I didn't get the correct results.

Thanks in advance for any help!

You can use “year” in bases too, here how if filter my books read in 2024:

date(note["Date read"]).year == 2024

If Bases is seeing your date-start as a string instead of a date, you could try this filter:

note["date-start"].slice(6) == 2024

But if that causes errors on some notes, then try:

note["date-start"].toString().slice(6) == 2024

Thanks a lot but this is not working.
I have a property named “date-read” for when I finish the book of “date” type.
The are the two errors I’m getting:

Filed to evaluate a filter. Type error in "date", parameter "input". Expecting String given Number

and

Filed to evaluate a filter. Type error in "date", parameter "input". Expecting String given List

Thanks a lot but Bases is giving the error that it can’t find function “slices” in Date.

Even with the second filter I mentioned?

If the second one also doesn’t work, then what’s the exact filter you used when you got the errors you posted in response to reaty?

Those errors seem to say that your property has inconsistent formatting throughout your notes—lists and strings even though you meant for them to be dates. Do you know whether, in source mode, all of your date-start and date-read properties are strictly like you mentioned:

---
date-start: 01/08/2024
date-read: 20/08/2024
---

… or are some (or all) YYYY-MM-DD in source mode? Or are some different?

The second filter neithet get errors nor results: it shows nothing.

In all notes both properties are of “data” type. When compiling the book’s note the property require the date in dd/mm/yyyy format, but in source mode is yyyy/mm/dd
(never checked the source mode, my fault. But still I don’t know what to do in order to solve :smiley: )

Edit:
after a lot of thinking and experimenting with a “test view” I’ve found this solution:

note["date-read"] > "2023-12-31"
and
note["date-read"] < "2025-01-01"

I think is not so elegant but it’s working. I think yesterday I’ve already tried this but it was not working.

Feel free to give me a better solution, and maybe a way to have the possibility to filter for date-read OR heard-finish (for audiobooks). I’ve not found a solution using this approach.

Feel free to give me a better solution

Since it works the way your showed, I would expect this to also work:

note["date-read"].year == 2024

I was under the impression you said that didn’t work, but I mention it again in case I misunderstood your response to reaty (or maybe I just misunderstood what you had already tried).

and maybe a way to have the possibility to filter for date-read OR heard-finish (for audiobooks)

To do “or” in the Filter maker, select “Any of the following are true”, like this:

Here’s what it looks like in code:

```base
views:
  - type: table
    name: Table
    filters:
      or:
        - note["date-read"].year == 2024
        - note["heard-finish"].year == 2024
    order:
      - file.name
      - formula.Untitled

```

Alternatively, if you would rather use the filter pairs you shared, then you could click “Add filter group” to create groups with “or” and “and”, like this:

In the code, it’s:

```base
views:
  - type: table
    name: Table
    filters:
      or:
        - and:
            - note["date-read"] >= "2024-01-01"
            - note["date-read"] < "2025-01-01"
        - and:
            - note["heard-finish"] >= "2024-01-01"
            - note["heard-finish"] < "2025-01-01"
    order:
      - file.name
      - formula.Untitled

```

Your solution is working (today, yesterday I didn’t get any result. I don’t understand why but since Informatics is an exact science… :rofl:)

These are my filters and now is working (tried with 2025 since there are less books)
Bases is still complaining about:

but I’m getting the correct results.
I wish I could understand why this error but hope to get what I need also tomorrow :rofl:
Thanks for your help and your patience!

Glad you got the formula working!

That error message means some of your date-read and/or date-heard values are in a format that is not a date, per Bases’s interpretation. It means that notes with the “incorrect” format won’t show up in your results, even if they are from the year you entered.

Several things can make the date format incorrect for Bases, such as being in a list, having a time zone offset, slashes instead of dashes, the year at the end instead of the beginning, or an number that’s out of range (like 2025-13-50).

If you want to clean the property values, one way to try to find those notes is to make a separate base with this filter:

note["date-start"]

… and this property formula:

note["date-start"].date()

That ought to show you which date-starts aren’t dates, like this:

And then do the same for heard-finish.

1 Like

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