A little confused about %ICUDateTime%

I need to do like that: if today is Monday returns "xxx1" , if Sunday returns "xxx7".

If using xxx%ICUDateTime%e%, got wrong result.

How to do that?

Can you show your macro, at least the relevant action(s)?

I tried it and it seems to work fine:

The only issue is that I was expecting "3" for "Wed" (my local day today) instead of "4".


My code is the same as you, showing "xxx4", but today is Wednesday in my country, should be showing "xxx3" instead.

Thanks for the clarification. Just by looking at your OP, I would not know you are having the same issue I said in my reply.

It looks like the counting begins with Sunday.

One way to get what you wanted is to minus 1 day:

1 Like

It works, thank you!

As an alternative you could use KM’s DOW() function. See the wiki https://wiki.keyboardmaestro.com/function/DOW

It returns 1 for Sunday, 2 for Monday, etc.

But @cmichaelaq wants 1 for Monday, 2 for Tuesday, etc.

Is it possible to get the wanted result from DOW()? I'd like to learn, as DOW() is more intuitive.

1 Like

DOW example:

also, you can do a comparison,
that if Today is SpecificDay, then return True

ie today is Wednesday = true:


Hi @hello, as @tiffle said, DOW() return 1 for Sunday, 2 for Monday, etc.
But @cmichaelaq wanted to return 7 for Sunday, 1 for Monday, etc.
My question is about how to use DOW() (if possible) to get what @cmichaelaq wanted.
Currently, only %ICUDateTimeMinus%1%Days%e% gets what is asked of.


Hi @martin, this is how I'd use DOW() in this situation:
KM 0 2021-06-02_22-55-36

The first action just creates a look-up table so that:

1 (Sunday) maps to "7"
2 (Monday) maps to "1"
3 (Tuesday) maps to "2"

(assuming Sunday is to be 7, Monday is to be 1, etc.)

The second actions then uses DOW() to extract the correct value from the look-up table.

It works but it's not really what I'd call elegant!


It might not be elegant, but it is brilliant. I would never be able to come up with a solution like this. Well done!

1 Like

Or just use this (elegant?) calculation: %Calculate%1+((DOW()+5) MOD 7)%


Thanks @SLWorona - I was searching for this elegant and brilliant solution of yours but just couldn't get my brain in gear! Much better!

1 Like


1 Like

Or this (so simple...) calculation: DOW()-1+7*(DOW()=1)


That’s very clever avoiding modulo arithmetic!

1 Like