Best Way to Find The Oldest Time?

Using the %ICUDateTime%HH:mm% Token I am setting a time stamp for when a macro runs for each user. When it launches again I want to make sure the macro runs for the oldest time stamp to prevent the macro from running for multiples users at one time to prevent my pc from running too many macros (yes, it happens, I run other macros too, this one can wait for each person and running one at a time is fine).

How can I have a list of %ICUDateTime%HH:mm% varialbes with random times and select the one that is the oldest out of lets say a list of 10.

e.g

11:13
11:45
11:58
12:23
11:01
12:45

etc

Time compare.kmmacros (6.8 KB)

Pretty Sure this works! I just thought really hard for a little bit. Feel free to look and see if its bullet proof or not. no Code just KM!

image

Hey Byrein,

Here's how I'd do that.

(I use military time, so AM/PM is not a problem.)

-Chris


Extract Latest Time from a List (24-Hour Time) v1.00.kmmacros (5.7 KB)

Just for fun – here's how I'd do that with AppleScript:

--------------------------------------------------------
# dNam: Christopher Stone <scriptmeister@thestoneforge.com>
# dMod: 2021/05/22 19:15
# Task: Extract the lastest time from a list.
--------------------------------------------------------
set timeList to paragraphs of text 2 thru -2 of "
12:45
11:13
11:45
23:22
23:21
11:58
12:23
11:01
"

set highTime to date (item 1 of timeList)

repeat with i in rest of timeList
   set tempTime to date (contents of i)
   if tempTime > highTime then
      set highTime to tempTime
   end if
end repeat

return text 1 thru -4 of time string of highTime
--------------------------------------------------------