Query to gather all notes on a specific date irrespective of year

How do I write an agent that can look at twelve years of notes and gather only those notes written on today’s date, day and month only?

i.e. a container for all notes “on this day”

Naturally, the container’s contents will vary each day.

There are two attributes that might be used, System $Created and User $PublicationDate, the only notes I’m interested in are those with $PublicationDate, which is in this format: 1/30/25, 09:55

Seems like it ought to be simple, but I’m stumped.

1 Like

Can I tentatively offer this kludgy, clunky, not-cool-at-all solution?

If I set $AgentQuery to

($PublicationDate.format("D") == date("today").format("D")) & ($PublicationDate.format("M0") == date("today").format("M0"))

Then I get this…

which on a quick test seems to do what you’re asking for (apologies if I’ve misunderstood…).

Bear in mind that I’m in the UK, so use “dd/mm/yyyy” (or “D/M0/y”) in Tinderbox-speak, so you may have to adapt it if that’s not your date format. (I’m not sure if it will need adapting, TBH.)

I am absolutely certain that this can be made simpler and that someone will be along in a minute to show you how, but perhaps it’s worth trying?

1 Like

Looks like it works, straight out of the box! Thanks!

Thought I was going to have to coerce dates into strings and then do some regex-fu nonsense.

You made it look easy! Much appreciated.

Thanks – it looked like an interesting problem, so I had a play…

I’m sure there’s a way of making it more elegant though.

1 Like

There’s no need to use .format. This should work:

day($PublicationDate)==day(date("today")) &&
month($PublicationDate)==month(date("today"))
1 Like

Well, for whatever it’s worth, that does not work.

Replaced the preceding query with the revised query and it gathered nothing.

Clicked away, went up to Update Agents Now and no change.

Replaced the revised query with the original query and all the posts came back.

Something may be amiss…

This is not an alternate to @brookter’s solution. Go with that. The following is just colouring in some of the contingent part of the process.

These date format codes are how we tell Tinderbox that from a Date-type value (which internally is number though you never see it) we want a String-type values of all or some of the data, which we do using used by Date.format(formatStr).

Thus format string "D" asks: from the source Date data, find the calendar day number and give it to me as a two character string. Thus, 2 February the "D" value would be "02" and for 14 February it would be "14". Format "M0" (M zero) does the same for the Date’s calendar month.

@brookter is quite right to note the scope for error with dd/mm (rest of world) vs. mm/dd (USA) ordering in some numeral date formats. His method neatly sidesteps that because as day and month are read discretely the query doesn’t involve d/m order. So the query works regardless.

We can do the functionally the same query as above but comparing numbers and not text by using Date.day() and Date.month(). Below, the line breaks in the query are only for legibility here:

($PublicationDate.day == date("today").day)
 & 
($PublicationDate.month == date("today").month)

Note this is not better/more efficient query than @brookter’s approach (certainly not at the power of a current Mac). Rather, it is just another way to do the same thing, as is so often possible in Tinderbox.

Noting that .day() and month() return either a one or two digit number, reminds us the the number of digits doesn’t matter as in the scenario a correct query outcome will match the number of characters and their value owing to the logic of their creation—even if the number of characters varies from date to date.

Therefore, we could also use the first .format() method but replacing format strings "D" and "M0" with "d" and "m". The result/efficiency is the same. So why have the two different formats for the same info. Well, it all depends if the next thing you’ll do needs a fixed number of characters, i.e. ‘02’ vs. ‘2’ such as affects the first nine day of a month and similarly the first none months in a year.

TL;DR? Use the query in the previous post. :slight_smile:

4 Likes