How do I Write an If Statement for If Current Time is After 11:30pm and Before 06:00am?

How do I Write an If Statement for If the current time is After 11:30pm and Before 06:00am?
So that when it's after 11:30pm (23:30) and before 06:30am it returns true.

Erg... I've looked at a few. posts, I know it's right in front of me.... somewhere.
I can't get it

thanx

1 Like

Hey there, an if statement between two hours on the dot is easy... see an example below. ↓

However, an if statement between half hours is more complex. I'll work on something this afternoon in between work calls.

If statement between 11pm and 6am.kmmacros (2.7 KB)

Macro-Image

Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.
System Information
  • macOS 13.5
  • Keyboard Maestro v10.2
3 Likes

Hey @cdthomer , I don't know why I couldn't get that!!! erg.. LOL////
Bro, don't bother with the minutes...
This solution is just fine.
FYI - I was messing with The NOW and TIME functions etc etc and just didn't get 'there'.
Again, thanx
Troy

2 Likes

Glad that works for your Troy! I just noticed though, the second condition should be <= for it to trigger between 6am and 7am. If it’s < it will only trigger before 6am.

1 Like

well, upon further working this into my solution....
If it's 1am, it won't trigger because it's not greater than 23.... no?

A simple, I call it 'barnyard' fix... would be to just enter HH is 11, 12 1 2 3 4 5 6, with if any condition met, then it would trigger .......

@tiffle erg... of course.... thanx man

2 Likes

You might want to try if any of the following are true in your If action!

4 Likes

@tiffle has you covered... I basically pulled that from one of my macros, but that runs things between 8am and 6pm, and forgot to change that to any instead of all.

2 Likes

Here's another approach...

Download: Between 11-30pm and 6-00am.kmmacros (5.8 KB)

Macro-Image


Macro-Notes
  • Macros are always disabled when imported into the Keyboard Maestro Editor.
    • The user must ensure the macro is enabled.
    • The user must also ensure the macro's parent macro-group is enabled.

System Information
  • macOS 13.4.1 (22F770820d)
  • Keyboard Maestro v10.2

2 Likes