Using && statement

I am new to programming and I am trying to learn how everything works. I am trying to determine how long the statePlant is on using millis(). I have it working almost like I want it but the problem is with my statement if(started && stopped) it shows the time elapsed when the sensor is started and then stopped as well as stopped and then started. Is there a way to make it print the elapsedTime only when started is activated and then when the stopped is activated?

if (started && stopped)
    {
      elapsedTime = stopTime - startTime; //How long did it take?
      Serial.print("Elapsed time in milliseconds");
      Serial.println(elapsedTime);
      
      started = false; //resets so the sensors can be tripped again
      stopped = false;
}

Any help is appreciated! My entire code is below.

//Using pushbutton to start the loop of counting plants and wheel slots and reading to SD card
#include <SD.h>

int ledLight = 5; //on/off light
int pushButton = 7; //Button input pin
int plantSensor = 2; //Plant Sensor
int wheelSensor = 3; //Wheel Sensor
int plantCounter = 0; //Plant Sensor Counter begin
int wheelCounter = 0;  //Wheel Sensor Counter begin
int buttonState = 0; //for on/off switch
int lastButtonState = 0; //for on/off switch
int buttonPushCounter = 0; //for on/off switch
int statePlant;
int laststatePlant = HIGH;
int stateWheel;
int laststateWheel = HIGH;
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers
int refreshrate = 10;
const int CS_PIN = 10; //for SD card
const int POW_PIN = 8; //for SD card
//Button
unsigned long startTime; //Store start of button press
unsigned long stopTime; //
unsigned long elapsedTime;
boolean started = false; //see if clock should be started button
boolean stopped = false; //see if clock should be stopped button
//Plant diameter
unsigned long startTime_dia; //Store start of button press
unsigned long stopTime_dia; //
unsigned long elapsedTime_dia;
boolean started_dia = false; //see if clock should be started button
boolean stopped_dia = false; //see if clock should be stopped button
//Wheel speed
unsigned long startTime_wheel; //Store start of button press
unsigned long stopTime_wheel; //
unsigned long elapsedTime_wheel;
boolean started_wheel = false; //see if clock should be started button
boolean stopped_wheel = false; //see if clock should be stopped button



void setup() {
  pinMode(pushButton, INPUT);
  pinMode(ledLight, OUTPUT);
  Serial.begin(9600);
  Serial.println("Initializing Card");
  pinMode(CS_PIN, OUTPUT);
  pinMode(POW_PIN, OUTPUT);
  digitalWrite(POW_PIN, HIGH);
  if (!SD.begin(CS_PIN)) {
    Serial.println("Card Failure");
    return;
  }
  Serial.println("Card Ready");
  
  File commandFile = SD.open("speed.txt");
  if (commandFile) {
    Serial.println("Reading Command File");
    while(commandFile.available()) {
      refreshrate = commandFile.parseInt();
    }
    Serial.print("Refresh Rate = ");
    Serial.print(refreshrate);
    Serial.println("ms");
    commandFile.close();
  }
  else {
    Serial.println("Could not read command file.");
    return;
  }
}



void loop()
{
  //ON/OFF switch loop
  
  buttonState = digitalRead(pushButton);
  if(buttonState != lastButtonState)
  {
  if (buttonState == HIGH){ //Check if button pressed
    delay(250); //debouncing
    buttonPushCounter++; //count button presses
    Serial.println("on");
    Serial.print("number of button pushes: ");
    Serial.println(buttonPushCounter);
  }
  delay(50);
  }
  if(buttonPushCounter%2 == 0){ //Light off if button pushed 0 or even number of times
    digitalWrite(ledLight, LOW); //Show system is off
  }
  else{ //Light on if button pushed odd number of times
    digitalWrite(ledLight, HIGH); //Show system is on
  }
  
  
  
  //Plant counting loop
  
  if(buttonPushCounter%2 == 0){ //System off if button pushed 0 or even number of times
    stopped = true; //Note that the button has been turned off
    stopTime = millis(); //Note the time when the button was off
  }
   
  else{ //System on if button pressed odd number of times
    started = true; // Note that the start button has been pressed
    startTime = millis(); //Note the time when the button was pressed
    int statePlant = digitalRead(plantSensor);
    if ( statePlant != laststatePlant) 
  {
    if(statePlant == HIGH) 
    {
      started_dia = true; //Plant is being sensed, start time
      startTime_dia = millis(); //Time when plant is sensed
      plantCounter=plantCounter+1;    
             File dataFile =SD.open("log.csv",FILE_WRITE);
       if(dataFile)
        dataFile.print((plantCounter));  //Logging plants to SD card
        dataFile.print(",");
        dataFile.print((((wheelCounter)/2)*4.3)); //Logging wheel slots to SD card
        dataFile.println("  Inches");
        dataFile.close();
        
        Serial.print((plantCounter)); //Serial Print plants
        Serial.print(",");
        Serial.println((((wheelCounter)/2)*4.3)); //Serial print wheel slots
        Serial.print("Plant Start time= ");
        Serial.print(startTime_dia);
        Serial.print(",");
        Serial.print("Plant stop time= ");
        Serial.println(stopTime_dia);
 
      }
     if(statePlant == LOW)
     {
       stopped_dia = true; //Plant is no longer sensed, stop time
       stopTime_dia = millis(); //Time when plant is no longer sensed

     }
     if(started_dia && stopped_dia)
     {
       elapsedTime_dia = (startTime_dia - stopTime_dia); //How long did it take to pass by the plant
       Serial.print("Time of plant= ");
       Serial.println(elapsedTime_dia);
     }
          
    }
     laststatePlant = statePlant;
  
  }
  if (started && stopped)
    {
      elapsedTime = stopTime - startTime; //How long did it take?
      Serial.print("Elapsed time in milliseconds");
      Serial.println(elapsedTime);
      
      started = false; //resets so the sensors can be tripped again
      stopped = false;
    }
  
  //Wheel hole counting loop
 
 if(buttonPushCounter%2 == 0){
 }
 else{
 int stateWheel = digitalRead(wheelSensor);
    if ( stateWheel !=laststateWheel)
      {
        if( stateWheel == HIGH)
        {
           stopped_wheel = true;
          stopped_wheel = millis();
          Serial.print("Wheel hole time= ");
          Serial.print(startTime_wheel);
          Serial.print(",");
          Serial.print("Wheel solid time= ");
          Serial.println(stopTime_wheel);
        }
        if( stateWheel == LOW)
        {
          started_wheel = true;
          startTime_wheel = millis();

        }
         if(started_wheel && stopped_wheel)
        {
         elapsedTime_wheel = (startTime_wheel - stopTime_wheel); //How long did it take to pass by the plant
         Serial.print("Time of wheel= ");
         Serial.println(elapsedTime_wheel);
     }
 
          
        laststateWheel = stateWheel;
        wheelCounter = wheelCounter+1;
      }
     }
  }

Is there a way to make it print the elapsedTime only when started is activated and then when the stopped is activated?

Yes, by setting started and stopped to true appropriately.

  buttonState = digitalRead(pushButton);
  if(buttonState != lastButtonState)
  {
  if (buttonState == HIGH){ //Check if button pressed

Are you really expecting a seed to press a switch? If not, some appropriate names would make the whole process easier to understand.

It is not clear how stopped can become true (under the conditions you defined) without started having become true first. In which case, only the state of stopped matters.