How would I compare the differences between time in 2 variables?
MyVar1= 2:30 PM
MyVar2 = 5:45 PM
With the difference between MyVar1 and MyVar2
"Duration: 3 Hour(s) and 15 Minutes" (or "Duration: 3.15 Hour(s)" will also work)
I tried using How to calculate time differences? as a guidance but was unsuccessful. Are there any examples of this or explanation? Most I have found are more elaborate calculations with dates. All mine are same day. Thanks!
The post you found definitely could solve what you need, but likely there are easier ways to do what you need, if you want only difference of time (and no day, month, year).
Something like this should work: Time Difference Calculations.kmmacros (21.1 KB)
I really like the approach/script that Chris @ccstone uses in his macro.
It provides a much more flexible and reliable determination of the source date/time than most any other solution, including mine.
Chris @ccstone, I just started using this macro. Thanks for your efforts.
I track my sleeping and waking hours and minutes by recording the time I go to sleep and the time I go to bed. I use this macro to calculate the hours and minutes. In calculating my sleeping time there is a problem with when there is a PM time in local_Time01 and an AM time in local_Time02 that the answer comes out the remained of the 24-hour count rather than the correct answer.
I'd like to be able to "Prompt for User Input" all at once yesterday's wake time (4:32a) and last night's bedtime (8:39p) and this morning's wake time (4:39a) and "display results in a window" both differences in time. (16.07 and 8.00) These are both recorded in my journal at the same time each morning.
Can you give me some direction to modify this macro for my needs?
In order to do date math that goes across a day boundary, you will need to include the date with the time. So if you do NOT enter the date in your journal, then when you run the macro you will need to get todays date as a reference, and use it to prefix both times accordingly, then do the math.