As you have seen with @telumire’s solution, adding/subtracting days from a formatted date (e.g., “YYYY0MM0DD
”) is not trivial, because of “overflow” handling needed to account for month and year numbers, which includes handling different number of days per month and leap years.
Fortunately, there is another method that avoids this complexity by allowing you to do “direct” math with dates.
To do this, you will need: https://tiddlytools.com/timer.html#TiddlyTools%2FTime%2FParseDate which adds a parsedate[...]
filter operator that can convert formatted dates to/from “unix time” numeric values that express datetime values as signed integers representing the number of milliseconds since the beginning of the “unix epoch” (midnight on January 1st, 1970)
After importing the above tiddler you will need to save-and-reload for the filter operator to be available. Then, you can write something like this:
<$let today=<<now "YYYY0MM0DD">> format="[UTC]YYYY0MM0DD"
oneday={{{ [[24]multiply[60]multiply[60]multiply[1000]] }}}
yesterday={{{ [<today>parsedate[unixtime]subtract<oneday>parsedate:unixtime<format>] }}}
tomorrow={{{ [<today>parsedate[unixtime]add<oneday>parsedate:unixtime<format>] }}}>
...
</$let>
Notes:
-
today
is the current date
-
format
is the desired output date format. Note the use of [UTC]
to bypass making adjustments for local timezone offsets.
-
oneday
is the total number of milliseconds in one day (24 hours X 60 mins/hr X 60 secs/min X 1000 msec/sec)
-
yesterday
and tomorrow
first use parsedate[unixtime]
to convert the formatted input date to a “unixtime” numeric value, then subtract or add the number of milliseconds in one day, and then convert the result back to a formatted date by using parsedate:unixtime<format>
.
enjoy,
-e