Using a Date variable for in ICUDateTimeFor

I want to enter a date variable in the ICUDatTimeFor function. Like:

%ICUDateTimeFor%TIME(%Variable%yeartest%, 4, 30)%EEE, MMM d, yyyy, w%

this returns :
%ICUDateTimeFor%TIME(2022, 4, 30)%EEE, MMM d, yyyy, w%
and I want :
za, apr. 30, 2022, 17

The trick here is the distinction between:

  • texts (small T character in the upper right of an entry field)
  • numeric calculations (small C character in the upper right of the field)

Functions like TIME() can only be directly evaluated in a calculation field, and Keyboard Maestro offers the two different actions:

  • Set variable to Text
  • Set variable to Calculation

so, to see the contrast, and get the kind of formatted date string that you want, we can:

  1. first create a calculated integer string representing seconds elapsed since the pop of champagne in 1970, and then
  2. use that inside a text expression:

Calculations vs Texts (for formatted date strings).kmmacros (2.0 KB)


Otherwise, if you do want to evaluate a Calculation expression somewhere inside a Text field, you can do it indirectly by wrapping the calculation inside the special %Calculate%...% token.

See:
Dates and Times [Keyboard Maestro Wiki]

3 Likes

I got it working super

1 Like