Can't combine WHERE conditions with OR

What I’m trying to do

I have notes with a field created which have the following format:

created: 2024-05-23T10:58

And now I have also notes which have the created field with the format:

created: 2024-05-23 08:30

I want to catch them both with my dataview query.
When I try them each like this it works:

Codesnippet 1

TABLE file.etags as "Tags"
WHERE contains(created,"2024-05-23")

Code Snippet 2

TABLE file.etags as "Tags"
WHERE dateformat(date(created),"yyyy-MM-dd") = "2024-05-23"

When I try to combine them like this the same results as in Codesnippet 2 are shown.

TABLE file.etags as "Tags"
WHERE dateformat(created,"yyyy-MM-dd") = "2024-05-23"
OR contains(created,"2024-05-23")

Things I have tried

I tried to find help in the forums. But I can’t tell what is wrong here.

Does someone now why it doesn’t work?

I should have mentioned that it is a dataview query…
Sorry about that. Unforunately I don’t know how to change the name of the topic or add the dataview tag.

You need to ensure both formats are consistently interpreted and processed. Use the date() function to handle both formats by explicitly converting created into a date object first and then applying your logic.

TABLE file.etags as "Tags"
WHERE dateformat(date(created), "yyyy-MM-dd") = "2024-05-23"
OR contains(created, "2024-05-23")

If it doesn’t work, you can try this, but … yeah, it’s not a solution that you want to have :slight_smile:

TABLE file.etags as "Tags"
WHERE date(created).year = 2024
AND date(created).month = 5
AND date(created).day = 23

Cheers, Marko :nerd_face:

This approach worked perfect!

TABLE file.etags as "Tags"
WHERE dateformat(date(created), "yyyy-MM-dd") = "2024-05-23"
OR contains(created, "2024-05-23")

Thank you so much for the fast help.

1 Like

You can also use the raw frontmatter which is a string, so no need to do any formatting…

```dataview
TABLE file.etags as "Tags"
WHERE contains(file.frontmatter.created, "2024-05-23")
```

https://blacksmithgu.github.io/obsidian-dataview/annotation/metadata-pages/

1 Like

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