Combining AND and OR in a query

I am having trouble creating a query that displays blocks that are:

  • Within a date range AND
  • are either a completed todo or have a specific tag

I have successfully got the first part working to show completed todos within a date range using the query

{{query (and (between [[2021-11-08]] [[2021-11-14]]) (todo done))}}

(dates are for example)

This shows me all completed todos within the date range as expected. My problem is understanding where to add an OR clause so that I also see non-todos that have a specific tag.

I have tried the following:

{{query (and (between [[2021-11-08]] [[2021-11-14]]) (or (todo done) [[FLAG]]))}}

This returns no results.

How else should I structure this query?

1 Like

I have no idea how to address this issue, but I made several attempts and found that

  1. {{query (and (todo done) [[FLAG]])}} returns the expected results.
  2. {{query (or (todo done) [[FLAG]])}} returns no results.

That is, this issue has nothing to do with AND.

2 Likes