How to Track Project Time With Given Start/End Time?

Hi Everyone,

I am new here: so first of all thank you all for all the great posts and very insightful discussions around KM here! These already helped me a lot with my small endeavors in Mac automation!

For this macro though I was not able to find a solution, despite searching and reading in the forum.

Oftentimes I have to track how much time I work for different projects in order to be able to bill by clients accordingly. With the tips from this forum I managed to come up with the following macro, which prompts me for input to describe my activity, name the according project and put in date and start as well as end time. From this it also calculates how long I have worked on the activity. It appends this input to a text file.

For now this only works like this: it subtracts the starting time from the current time. What I cannot get to work is to calculate the work duration from a given EndTime minus the given StartTime. How can this be done? I saw some suggestions for scripts, but do not know how to include them into this macro.

I would be most thankful for any pointers towards a solution.

Hey @entry,

What you're thinking is very common for people getting introduced to date/time math, but it doesn't compute (so to speak).

Take a look at this.

(With Format is in the gear menu and contextual menu of the calculation action.)

The NOW() function returns Unix time.

"The unix time stamp is a way to track time as a running total of seconds. This count starts at the Unix Epoch on January 1st, 1970 at UTC."

It's much easier to do math with integers than with timestamps like 09:45 - 08:00.

Dates and Times [Keyboard Maestro Wiki]

Don't miss the forum links at the bottom of the page.


Date Math -- End-Time Minus Start-Time = Duration v1.00.kmmacros (7.0 KB)
Keyboard Maestro Export


Thank you very much! That helps me a lot.

1 Like