Help with now Macro

Hello everyone

I am trying to write a very simple filter to find all the tiddlers the titles of which are prefixed by todays date.

The following works as expected

[all[]]-[!prefix[2025-02-17]]

But when I use the now Macro

[all[]]-[!prefix[<now YYYY-0MM-0DD>]]

it does not return any matches.

What am I doing wrong?

Cheers, Rob

Try

[all[]prefix<now YYYY-0MM-0DD>]

Note that the < brackets replace the square brackets.

I suspect that your macro isn’t rendered inside the filter and the only trick I know as wikitext apprentice is to enforce the rendering by using a wikify widget and capture the rendered value in a variable. Have a look at the code below:

<<now YYYY-0MM-0DD>>

{{{[<now YYYY-0MM-0DD>]}}}

{{{[[<now YYYY-0MM-0DD>]]}}}

<$wikify name="mydate" text="<<now YYYY-0MM-0DD>>">
<<mydate>>
</$wikify>

<$wikify name="mydate" text="<<now YYYY-0MM-0DD>>">
{{{[<mydate>]}}}
</$wikify>

This renders as:

2025-02-18

2025-02-18
<now YYYY-0MM-0DD>
2025-02-18

2025-02-18

As already noted by @Mark_S, the brackets for filter operands indicate how the operand is to be interpreted:

  • For literal values use square brackets (e.g., prefix[somevalue])
  • For variables/macros, use angle brackets (e.g., prefix<somevariable>)
  • For tiddler field references, use curly brackets (e.g., prefix{!!somefield})

Also note that for your specific filter, you can greatly simplify the entire filter:

  • You don’t need to specify [all[]], as it is implied when no other Selection Constructor operator is present at the beginning of a filter run.
  • -[!prefix<now YYYY-0MM0DD>] is a double negative, and is equlvalent to just [prefix<now YYYY-0MM0DD>]

Thus, you can just write:

[prefix<now YYYY-0MM0DD>]

enjoy,
-e

adding the requisite link to Those Pesky Brackets which explains how / where / when to use all the different brackets :slight_smile:

edit: … although on reviewing that page it doesn’t seem there is an example of this use case, i.e using a variable as an operator parameter and not by itself in a filter run. that might be a good addition as it seems to come up fairly often.

1 Like

Many thanks to you all for your input and helpful advice. I have now managed to achieve what I set out to do.

At first I struggled to insert the suggested code into a $list filter run, but with the help of Those Pesky Brackets I worked it out.

I have learnt a great deal from this. Thanks again everyone for the time you put in to helping out a rookie.

Cheers, Rob

2 Likes