Need help for a complex search


#1

Hello,

I try to define a pretty complex search for my todays items but unfortunately I can’t make it work:

! Today @search(@due =[d] today or @today except @done or @recurring >=[d] today and @recurring <=[d] tomorrow)

Can you please point me on my mistake?

Thanks!


#2

I am about to go to bed, but just giving it a quick glance, it looks as if you need to add several parenthesis to some of you statements (think like math and operators). Not having them in the right places makes things very confusing to even understand. For example, I have no idea what you are trying to do with the recurring tags. I can give you a proper query tomorrow; but just to make sure, could you just go through the logic of your query and what you are trying to do.


#3

Like I mentioned before, you need to use parenthesis or the computer will not know what to do. I think this is what you want is,

(@due =[d] today or @today) except (@done or (@recurring >=[d] today and @recurring <=[d] tomorrow))

  1. Get me all the due tags that are today or today tags
    (@due =[d] today or @today)
  2. But I don’t want the following
    except (@done///* or
    Now, if this would be English, you would have to use comas to figure out where one thing is connected to the other one. Since it is not, this is a good rule. If you just have to use a coma in English, then you know that the computer will not understand you. Try to use parenthesis to define/explain it.
  3. Since I am assuming that the following is a single unit of though that you also want to exclude, use parenthesis then.
    (@recurring >=[d] today and @recurring <=[d] tomorrow)

That is how you end with the following,

(@due =[d] today or @today) except (@done or (@recurring >=[d] today and @recurring <=[d] tomorrow))

That being said, your query will fail if you have children under tasks or projects that are done. In other words, the following will still be a valid result to your query. Because although the project is done, the children are not. So it will still appear.

Project: @done
	- This is a task @due(...)

I will recommend you to use Paths(read about it on the documentation) to eliminate the children of the done tasks, notes, or projects. It would be something like,

(@due =[d] today or @today) except (@done///* or (@recurring >=[d] today and @recurring <=[d] tomorrow))

Also, let me ask you again about your reason to use @recurring like you did since you wrote the following.
@recurring >=[d] today and @recurring <=[d] tomorrow


#4

Thank you very much for your detailed help, Victor! I really appreciate this.

I understand everything, only the question regarding the @recurring I don’t get. What do you mean with:

Why not use @recurring by itself instead?

Thanks again!


#6

Ok, let’s step back from the details and let me describe what I try to get.

The results of this query should be my initial overview of all things:

  • What is due today
  • What routines (defined via @recurring(today) if it’s a daily thing or @recurring(Monday) if it’s only on a certain day)

The first part of the query runs since months pretty stable for me:

Today @search(@due =[d] today///* or @today except @done)

Last week I read in this forum about the option to define recurring tasks, so I tried that in a separate query:

Recurring Today @search(@recurring >=[d] today and @recurring <=[d] tomorrow)

That worked also well. Next thought was, since I need both queries combined. I am aware o the whole basics with parenthesises and nesting queries. But all I tried, I could not combine these in a saved query.

First try:

savedSearcg @search((@due =[d] today///* or @today except @done) or (@recurring >=[d] today and @recurring <=[d] tomorrow))

Results in a red (=error) format

Next try:

MyNewSavedSearch @search(((@due =[d] today///* or @today) except @done) or (@recurring >=[d] today and @recurring <=[d] tomorrow))

Also no luck. And that war the point I wrote my initial post. But I have to admit it was in-between on something and I wasn’t very precise.


#7

Ohhh. It all makes sense. I am going to brake everything in little pieces.

(@due =[d] today or @today) except (@done///* or (@recurring >=[d] today and @recurring <=[d] tomorrow))

I believe that we already understand the first part. Since the recurring part of your equation was after the “except”, you were actually hiding things that you wanted to see. But before we place that in the right place, lets fix that part of the statement.

If I understand correctly, you only want to get things that.
A) Are recurring.
B) The recurring tag is due today.

@recurring >=[d] today and @recurring <[d] tomorrow

That will do it. I eliminated the equal part after the tomorrow since you only wanted things due today. Going back the the first part of the search you understood,

(@due =[d] today or @today) except @done///*

Now just add the last statement in the section where you are describing things you want to find.

((@due =[d] today or @today) or (@recurring >=[d] today and @recurring <[d] tomorrow)) except @done///*

Technically, I believe you could eliminate a parenthesis, but I tend to build complex queries by dividing them into little chunks that I put together. I like to keep the parenthesis so that I can later understand my logic. No kidding, I have found papers I wrote 7-10 years ago that I marvel I actually wrote since I have almost no recollection of them.

In case you wanted to know what I was talking about eliminating a parenthesis, here it is,

@due =[d] today or @today or (@recurring >=[d] today and @recurring <[d] tomorrow) except @done///*

Just don’t eliminate the parenthesis on the recurring part or you will have something completely different.


#8

That nails it exactly:

Wow, many thanks for that! That was awesome!