Need help on multitasking program

condition: motor need to run 1 hr based on day time between(5 to 8) and water level in tank greater than 150 cm and

code:

if (now.hour()>= 8 && now.hour()<= 15 && distance <= 150)
{
if((relay1state = HIGH) && (currentMillis - previousMillis1 >= PumpStart))
{
relay1state = LOW;
Serial.print("Main Pump ON");
Serial.print(" , ");
digitalWrite(relay1, relay1state);
previousMillis1 = currentMillis;
}

else if((relay1state = LOW) && (currentMillis - previousMillis1 >= PumpStop))
{
relay1state = HIGH;
Serial.print("Main Pump OFF");
Serial.print(" , ");
digitalWrite(relay1, relay1state);
previousMillis1 = currentMillis;

}

else
relay1state = HIGH;
Serial.print("Else Main Pump OFF");
Serial.print(" , ");
digitalWrite(relay1, relay1state);

This part looks suspect -- Maybe try tools/autoformat to make the indenting match the syntax and see if the logic looks as you intend.

Oh, and please post functional code and use the code tag.

You posted code, good but...

Please read this topic: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

Post the entire code, first autoformatted in the IDE, then pasted in code tags.

What's is Your question, the schematics?
What happens and what do You want to happen?

It looks like you probably meant:
if((relay1state == HIGH)