Hi all, I need to paste (or type) yesterday's date into a field in a web page. How can I get yesterday's date using KM?
Also, the date I paste or type needs to be 8 numbers in the format (ie:) 01/11/2024 (KM seems to only offer 01/11/24 - Note, I can fix this by arrowing to the 'century' location and typing in '20' - but it'd be cool if KM offers date with the century already built in).
Is there a way to do these things?
For yesterday's date, I've thought that I could create a variable at 11:59pm, then retrieve that as many times as I need after midnight (LOL, but I don't know how to do variables - and it seems it would be easier if KM could do it for me).
Thanks everyone!
Try the %ICUDateTimePlus%
token, as it will let you both adjust the day one backwards and control the format:
%ICUDateTimePlus%[amount of time]%[unit of time]%[output date format]%
-rob.
Awesome! Thanks!
I didn't use your verbiage, rather I clicked your %ICUDateTimePlus% token link and from there, I was able to do it this way for date minus 1: %ICUDateTimeMinus%1%Days%MM/dd/yyyy%
And this way for today's date: %ICUDateTime%MM/dd/yyyy%
Are these returned dates based upon GMT time?
If not, what do I add to %ICUDateTime%MM/dd/yyyy% to get it use my local time (8 hours behind GMT)?
Thanks again!
Who knows ... actually, the wiki knows, but I have to re-read it any time I'm doing anything with dates and times. It seems like they return local times, but I think that depends on which one you're using and how you're using it. A simple test with...
%ICUDateTimePlus%1%Hour%yyyy.MM.dd hh:mm:ss%
...on my Mac returned the current local time plus one hour. But there's a bit on the Dates & Times wiki page that talks about GMT offset if you're using certain date and time functions:
Since TIME() and NOW() returns the specified date/time in GMT
, you can adjust for your local time zone by subtracting the GMTOFFSET()function
Date and time math is not my strong suit, unfortunately.
-rob.
The ICUDateTime et al tokens display the time in the local timezone.
So %ICUDateTimeMinus%1%Days%MM/dd/yyyy%
will always give yesterday’s date in the local timezone, presuming you are using it in the middle of the day some time.
If you are using it right around midnight on a day (plus or minus a day) that changes daylight savings, then all bets are off as there is no single answer to the question of what the date was 24 hours before.
You could use
%ICUDateTimeFor%TIME(YEAR(), MONTH(), DAY()-1,12,0,0)%MM/dd/yyyy%
which should always give yesterdays date, unless you are more than 12 hours away from GMT (which is technically possible).
Basically, no matter how complex you think dates and times are, they are a thousand times more complex than that.
You got that right! I still have nightmares about dealing with timezones and DST. I mean, when we fall back an hour, which happens at 2:00 IIRC, then what time is it at 1:35 AM? The answer is the cat died.
Thank you Peter!
I was able to get the proper dates (yesterday and today) entered into the boxes they needed to be entered into. Last night (after putting a 10 minute pause into my macro), I ran the macro at 11:55pm and it still entered as it should have (2 days apart since it ran across the local date change).
Thanks again!,
Chris