I got stuck with timer off for long time--30 minutes

I want to set timer off for my Fan using arduino, but it doesn't work as I expected -- I mean it doesn't stop when I set any time for turning off.
Could you please take a look at my code and tell me how to fix my issue.

unsigned long CurMillis;
const unsigned long interval = 1800000; // 30 minute interval 1000x60x30
void setup() 
So5Count = map (analogRead(A0), 0, 4096, 0, 10); 

void loop()

if (So5Count != 0) {
        CurMillis = millis();
        if ((millis() - CurMillis) >= interval)  // 0,5h compaire
        {
          So5Count--;                        // each time finish 30 minute will reduce counter
          CurMillis = millis();  // update time for next fighting
          if (So5Count == 0) {
           
            digitalWrite(SsOut, HIGH);    // turn off motor
          }
        }
        
      }
}

I am not sure how your system is intended to work, but this:

        CurMillis = millis();
        if ((millis() - CurMillis) >= interval)  // 0,5h compaire

Means that millis and CurMillis will never differ by more than a millisecond when you compare them.

I thought:
In first line, let assume millis = 100 ms, then it pushed this value to Curmillis
Then go to 2nd line, millis now keep going let say 101ms and so on. Untill the difference is equal or bigger than 30minute
Then reset couNter for next round till So5count = 0
—————

So my thinking is wrong? Do you have another ideas?
Many thanks for reading my issue

Embehu:
I thought:
In first line, let assume millis = 100 ms, then it pushed this value to Curmillis
Then go to 2nd line, millis now keep going let say 101ms and so on. Untill the difference is equal or bigger than 30minute
Then reset couNter for next round till So5count = 0
—————

So my thinking is wrong? Do you have another ideas?
Many thanks for reading my issue

Yes, it is wrong. It won’t “keep going” because the next time (every time) through loop(), the first line is executed again. Try:

        if ((millis() - CurMillis) >= interval)  // 0,5h compaire
        {
        CurMillis = millis();

You do not need the parantheses around the subtraction, either:

        if ( millis() - CurMillis >= interval)  // 0,5h compaire
        {
        CurMillis = millis();

because of the precedence of operators.

Yeah. I got it, I was not thinking about the loop. Thank you so much! I will try it later on.

By the way, in another post I commented on the naming conventions for time stamps. This is an example of a bad one. Because, 'CurMillis' expands to "current millis()". In fact, after half an hour has passed it can hardly be called "current". Thus it is could cause confusion. 'currentMillis' or similar name legitimately should applied only to the variable that is used to capture the value of millis() each time through loop(). Something like 'lastMillis', 'previousMillis', or similar is a more appropriate name.