Date conversion using variable

Hello Folks,

In an effort to try to help someone, I got stuck.

For the most part, I know how to use basic ICU tokens. However, I do not know how to add days to a date other than Today's date. For example, if using the drop down date format, within the Prompt for User action, I don't know how to use that variable, to add days, in an %ICUDateTimeFor% token. So if I select, 10/3/2023, I don't know how to use that Local__Date variable to add 5 days and display 10/8/2023.

Macro Image- - Where it says Help is where I need the date displayed in the yyyy-mm-dd format.

Here is the macro:
Date and convert - Demo.kmmacros (4.6 KB)

If you can help, thanks as always.


This might help you:

Specifically this section:

  • Relative to some other anchor date

    • two weeks before Sep 28 2015
      %ICUDateTimeFor%TIME(2015, 9, 28-14)%EEE, MMM d, yyyy%

    • Week 20 of 2016
      %ICUDateTimeFor%TIME(2016, 1, 1+19*7)%EEE, MMM d, yyyy%

    • Six weeks after Apr 20 2016
      %ICUDateTimeFor%TIME(2016, 4, 20+6*7)%EEE, MMM d, yyyy%

I can’t be more specific as I’m a long way from my desk! Anyway - hope it helps.

Hello @tiffle,

Thanks for the suggestion. I read that post a few times before asking. I'm pretty sure if you were at your machine, you would have solved it because you are always so helpful.

I figured it out that I had to perform a set to calculation action (example below):

set Local__Date to Local__Date + (5 * 24 * 60 * 60)

Then I was able to solve it . I'm sure there is an easier way. Maybe it's in the post but I got to cluttered to see it. I just thought I could perform it with a single ICU Token.

Anyway, here is the macro for those interested. Please feel free to chop it up and educate me. I'm pretty sure if @mrpasini was around, as well, he would have this type of code in a disabled macro on his NAS drive. :slight_smile:

Date and convert - Demo.kmmacros (13.5 KB)

Take care all!

:upside_down_face: LOL. I think you nailed it, @kcwhat. I might suggest doing the math all at once ( * 86400) to make me look smarter than I am, but it's Sunday and my only day of rest.

:smiley: - You are smart and you deserve your respect!



1 Like