Create ANY date and then modify it

I want to create ANY date and then add 1 to it.

So in my test macro I'm expecting DateTestTomorrow to be 2017-07-26 and not 2017-07-27. At worst I would think it would be off by 1 day and not 2 but I suppose I'm overlooking something.

What am I doing wrong?

Keyboard Maestro Actions.kmactions (0.6 KB)

When you create a date using the TIME() function, you need to include a time of noon, as in:
TIME(2017,7,25,12,0,0)

For more info, see Mixing Date/Time Functions and Tokens in the KM Wiki.


Let me add that Date/Time math can be a very confusing subject.  At one point I thought that use of the `GMTOFFSET()` function would allow us to always properly account for differences in local vs GMT time.  But, unfortunately, it does not always work due to Daylight Saving Time (DST).

Perhaps this discussion will help:
https://forum.keyboardmaestro.com/t/issue-with-date-time-functions/5856/15?u=jmichaeltx
1 Like

Your second action’s token makes no sense.

The ICUDateTimePlus field takes the current time, and adds the second parameter to it, in units of the third parameter.

Your third parameter is “DateTestToday” which is considered to be “Days” because it starts with a “D”.

So your token is effectively:

%ICUDateTimePlus%1%Days%yyyy-MM-dd%

If you want the day after the first token, use:

%ICUDateTimeFor%TIME(2017,7,25)-GMTOFFSET()+86400%yyyy-MM-dd%

86400 being the number of seconds in a day.

1 Like

@peternlewis, @JMichaelTX - many thanks as always!

@peternlewis - Because it starts with a D? What’s that all about?

Also there is a slight typo for anyone who needs it perfect:
%ICUDateTimeFor%TIME(2017,7,25)-GMTOFFSET()+86400%yyyy-MM-dd%

I used the answers to my question to create a macro that looks up a single date in Gmail.

To do this you normally have to specify a before and after date with a difference of one and in the right order.

It's too much for me to think about in the moment when I already have a single date on my mind.

Gmail- Look up date.kmmacros (4.4 KB)

1 Like

Days, Weeks, Months, Hours, Minutes, Seconds.

Just the first letter is considered.

Thanks. Sorry. Fixed.