Compare date YAML to today's note

I feel like I’m close here. I have a YAML field on notes for “#person” called “reachout” that shows a date when I want to reach out to a given person.

On “today’s note”, I just want to show all of the people to reach out to that day, along with any that have older dates that I’ve missed.

TABLE email,phone
FROM #person
WHERE contains(reachout, “”) AND date(reachout) <=

I have contains(reachout, “”) because I’ll have a bunch of contacts with no need for this, and then the second half should pull those with a date earlier than the date of that daily note. However, it’s showing no results when I know it should.

I think that bit is not quite doing what you want it to do. What does the “reachout” field look like on notes that don’t need it? Is it blank? Absent?

General Investigation strategy for something like this: add columns to your table with the fields you are using in your query to make sure they look like what you expect. E.g. in this case I might add to your existing columns of email, phone a column with reachout and another column with date(reachout), temporarily remove your WHERE line (or half of it) so you get results (you can always add something like LIMIT 10 as a last line if removing WHERE would give you wayyyy too many), and make sure your results match your expectations.

Great tips, thanks!

For those that don’t need it, I plan to have it be absent (hence the “contains” qualifier).

Using your test column idea, both versions show “June 25, 2022”, meaning it’s pulling correctly and theoretically should show up on today’s note, but it’s still “no results…”

That is promising! Maybe add a column for then? (Yes it’ll show the same thing for every row, but the practice of just sticking all the different things in columns works for me because then I know I’m getting dataview’s interpretation of all the stuff at the same time while I’m investigating.) You could also add a column for date(reachout) <= AS "Reachout Before Today" (or some other name of your choosing…) and see what appears there!

Below may be just “fun facts” since this doesn’t seem to be your issue, but for clarity:

Then you can simplify the bit before the AND to just WHERE reachout, which will check whether reachout is present or not.

Contains is for checking whether a string or a list (in your case the value of the reachout field) has some thing in it. I suppose a non-existing field does not contain “” and an existing field does, so it works, but I was very confused when I looked at it!

That solved it! Somehow removing my “contains” mess and just adding the reachout as a solo variable did the job.

To be clear, this is the line and it seems to be doing exactly what I want:

WHERE reachout AND date(reachout) <=

I’m a bit confused why the other way would break it, but glad to have it solved. Now to go manually add dates to hundreds of items. :slight_smile:

I really appreciate your help!

1 Like

So I guess it is impossible to “contain” the empty string. Today I learned, thanks for sharing!

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