what is wrong with my if condition ?

I am trying to set solenoid state to off when its night hour so

I am doing

  if (getHour() >= 19  && getHour() <= 24) || (getHour() >= 1 && getHour() <= 7) {
    SOLENOID_STATE = false;
  }

but I get error saying

expected primary-expression before ‘||’ token

what am I doing wrong ?

does C compiler of Arduino groups && and &&'s together and what is asides of || as separate , I mean is it like :

  if (getHour() >= 19  && getHour() <= 24 || getHour() >= 1 && getHour() <= 7) {
    SOLENOID_STATE = false;
  }
  if ((getHour() >= 19  && getHour() <= 24) || (getHour() >= 1 && getHour() <= 7)) {
    SOLENOID_STATE = false;
  }

Forgot 2 of them bracket things.

-jim lee

The if statement ends when the ) that matches the ( after the if keyword. Where does that happen in your first snippet?

  if (getHour() >= 19  && getHour() <= 24) || (getHour() >= 1 && getHour() <= 7) {
    SOLENOID_STATE = false;
  }

Match your ( ).
When in doubt, use () to tell the compiler the order you want.

if ((getHour() >= 19  && getHour() <= 24) || (getHour() >= 1 && getHour() <= 7))
{
    SOLENOID_STATE = false;
}

.