Date as a link in due field

There are some tiddlers whose ‘due’ field is set to ‘[2021-09-02 Thu]’.

I wanted to use a filter to select these using now macro.

So, I tried:

<$list filter="[due[<<now "YYYY-0MM-0DD ddd">>]]">
<$link />
</$list>

and this:

<$vars todd="[<<now "YYYY-0MM-0DD ddd">>]">
<$list filter="[due<todd>]">
  <$link /><br><br>
</$list>
</$vars>

None work. I think I am not getting the syntax correct. But I am unable to pinpoint the error.

How do I get this working?

1 Like

Here’s the proper syntax:

<$vars todd=<<now "YYYY-0MM-0DD ddd">>>
<$list filter="[due<todd>]">
  <$link /><br><br>
</$list>
</$vars>
  • To assign the results of the <<now>> macro to a variable, leave off the quotes and square brackets. Otherwise, you are just storing a literal text value without actually processing the <<now>> macro.

  • Also, if you actually want to assign a literal text value to a variable, you can’t “nest” the doublequotes in the variable value, so you would have to use singlequotes as the text delimiter, e.g. <$vars foo='this text contains "doublequotes" like this'>

  • As of TW v5.1.23 (the current release), you can only reference variables – <todd>– or macros with no parameters – <now> – directly in the filter syntax… and keep in mind that, unlike general wikitext content or widget parameter values, within filter syntax you only use a single set of brackets to enclose the variable name.

  • However, starting with TW v5.2.0 (which has not yet been released), you will be able to use macros that include literal parameters (e.g, <now "YYYY-0MM-0DD ddd">) directly within the filter syntax.

  • Thus, in TW v5.2.0, you should be able to write:

<$list filter="[due<now "YYYY-0MM-0DD ddd">]">
  <$link /><br><br>
</$list>
  • Note that I’m not 100% certain about the use of nested double-quotes (") inside the filter. You might have to use singlequotes (’) to surround the macro parameter (e.g., <now 'YYYY-0MM-0DD ddd'>)

enjoy,
-e

1 Like

Thanks.

But the code you have selects tiddlers with ‘due’ set to ‘2021-02-09 Thu’. But target tiddlers have ‘due’ set to ‘[[2021-09-02 Thu]]’. This makes it into a link to the journal tiddler when searched or displayed.

How do I get those square brackets?

By the way, being able to add macros to filters would be helpful.

The [due<todd>] filter looks for an exact matching value contained in the “due” field. However, since the value in that field is surrounded by doubled squarebrackets, you can treat the “due” field contents as a list, and use the “contains” filter operator, like this: <$list filter="[contains:due<todd>]">

-e

1 Like

@EricShulman Thanks! That did it.