Convert German date format into International (ISO) format and output it into new variables

Hello guys,

I’ve been trying to figure this out myself, but after a lot of searching, reading and testing, I am realising that this might be above my current abilities.

What I am trying to achieve is pretty straight forward on paper.

I have two dates variables:
„From“
„To“

This is the date format they output:
21.06.2020
27.06.2020

My Goal:
I need to covert that %Variable%From% and %Variable%To% into an American date format and I need that info to be outputted into two new variables such as %Variable%FromUS% and of course %Variable%ToUS%

This would be the text outcome of those new variables:
2020-06-21
2020-06-27

I am on Keyboard Maestro 9.0.5 on macOS 10.15.5

Please help :slight_smile:

Tanks a lot in advance.

Cheers

If the variables are always in that format, it's fairly straightforward to rearrange them into US format with regex:

Example Macro.kmmacros (1.6 KB)

1 Like

Careful about the assumption this is the American date format. Often I see things like 05/04/2020 - today's date (where the month comes before the day and then finally the year).

But the method of decomposing the German date format and composing a USAn one from it still holds.

Hello @gglick,

thanks a lot for the quick and precise answer. This works as expected and I guess I have to add to my list of things to learn "regex" :slight_smile:

@MartinPacker thanks for specifying, in my case the output format will always be same. So this definitely does the work.

In 20 years of informatics, I can honestly say this is the best forum I have ever had the pleasure to be part of. Love this place, learning so much from you guys.

Cheers :beer:

1 Like

@gglick has provided you with the solution, but FYI the "US" format that you asked for is generally known as the "ISO" or "International" format: "YYYY-MM-DD"
The typical U.S. (American) format is that given by "MM/DD/YYYY":

For more information, see Dates and Times .

I have revised your Topic Title to be more accurate.

1 Like

Hello @JMichaelTX, thank you for the heads up. Learned one more thing. Appreciate it + thanks for updating the title, that will surely help others.

1 Like