Previous Date Variables - Best Way?

I want to create some variables that would return the date for previous days
And then use those in variables in other text replacement macros

e.g.
Last Wednesday = %xdlw%
Last Thursday = %xdlth%

Is the best way to do this to create shell scripts, that save results to variables, for each day and trigger those every 24 hours?

e.g. - Last Wednesday

#!/bin/bash
day='Wed'
today=`date "+%a"`
if [ "$today" == "$day" ] 
    then
  VAR=$(date -v-7d "+%m/%d/%Y")
else
  VAR=$(date -v-"$day" "+%m/%d/%Y")
fi
echo -n $VAR

Unless you need to use a Shell Script for other reasons, the easiest way is to use the built-in KM tokens for ICU Date/Time.

See Dates and Times [Keyboard Maestro Wiki]

1 Like

I see nothing there that would allow me to insert the date of the previous Wednesday into a text macro
That is why I was using the script

Maybe this will help:

4 Likes

Thanks!