How to Compare the Current Hour to a Given Value

Hello All,

I'm a new user, and I'm having some newbie issues related to compare times and if statements.

I'm trying to compare whether the current time is before 18:00 in an IF statement.

In the IF statement, I selected the “If all the following are true” option and then added the condition calculation. Inside the calculation field I tried the NOW()<18:00 however this formula or statement is in red and I don't know how to make it work.

Any approach options on how to do this will be appreciated.


NOW() returns the "time in seconds since the epoch", which will almost certainly be more than 18! And the calculation is red because "18:00" isn't a valid number.

But if you look at the Functions page you'll see there's one called HOUR(), which is probably what you want:

HOUR() < 18

@Nige_S has you covered for dealing with the hour.

For more information you may wish to review this topic:

KM Dates & Times: Notes on Anchors, Intervals, and Translations

And this guide on the Keyboard Maestro Wiki:

Dates and Times [Keyboard Maestro Wiki]

Nige_S Thanks for your answer
I did take a look into your suggestions and I did use the hour() function. The function allowed me to achieve what I was trying to do.

Many thanks
For your answer

1 Like

CCStone thanks for your reply
Nige_S indications help me to achieved what I was trying to do. I will also take a look into your links about date and time.

Many thanks

1 Like