Setting a date attribute automatically

Hello, fellow TBXers,

I am trying to create a daily activity log in Tinderbox. I created a container where I store notes describing daily achievements.

I also added a User date attribute called $CompletionDate. I would like to have $CompletionDate set to “today” unless I manually specified a date.

I tried the following Rule:

If(!$CompletionDate){$CompletionDate=today};

However, the date is set to “never” rather than “today.”

Anyway, your help is most welcome.

Thanks!

Mariano

Is the ‘If’ above a typo? Action code is case sensitive. If I change ‘If’ to ‘if’ your code works for me. Slightly better usage - so as to get into good habits and not get bitten in more complex code - is to use date() when setting dates, even when using date designators. Thus:

if(!$CompletionDate){$CompletionDate=date("today")};

Thank you very much @mwra, bloody autocorrect :slight_smile:

It works! I did spend, nonetheless, several minutes scratching my head… :grimacing:

Thanks once more.

M

1 Like

@mwra For me this is not working since every minute the $CompletionDate gets updated e.g. it adds another minute to the date.

How can one stamp a CompletionDate that represents the minute of completion and then does not change anymore.

My Rule (!) looks like this:

if($Checked==true){$Badge=ok; $CompletionDate=date("today")} else {$Badge=calendar; $CompletionDate=never};

Can someone help on this?

Thanks

If you want a one-time rule then modify your rule with $Rule=; as follows:

if($Checked==true){$Badge=ok; $CompletionDate=date("today");$Rule=;} else {$Badge=calendar; $CompletionDate=never};

This will wipe out the rule as soon as it runs once.

If you are going to use this in a lot of notes, then maybe consider using an Edict or a low-frequency Agent?

Or, change

To

$CompletionDate|=date("today");

See the logical OR operator. This code will run continuously but only set $CompletionDate once. That said, I think @PaulWalters answer above is probably as, if not more, practical.

Just to the point, Maestro @PaulWalters. It works perfectly well for me. Thank you!

Thank you @mwra. Works well, too. But just as you said, @PaulWalters’ suggestion might be the way to go in this very setting.

1 Like