In Keyboard Maestro, perform date math with predefined date variable?

Hello! I’m having trouble finding the answer to this elsewhere.

All the date math information I can find for KM is generally based on the current date (i.e. 3 days before today). Is there a way I can add a variable with a predefined date? Specifically the macro asks the user to enter the relevant date (say, March 20th) and I would like to perform date math later in the macro (3 days prior to March 20th, giving March 17th).

While less important, is there a way to have KM fill in a date based on a day of the week? Specifically having it default to last Friday’s date?

Thanks so much!

This can be solved by executing a terminal command from KM.

You’ll find lots of relevant information about date math in the terminal here.

From the above site:

The interesting part of the --date option is that it allows you to specify date strings in a variety of ways. For example, given the above date of “March 1, 2015”, you can calculate dates relative to it:

$ date --date 'March 1, 2015 +7 days'
Sun Mar  8 00:00:00 MST 2015

In you case, the terminal command should be something like:

$ date --date '%KM Date% -3 days'

Where %KM Date% is the selected date in KM.