How do i want to use relay?

I want to use relay with real time clock module ds3231 to make a self watering machine with the combination of water pump,thats why i need relay,i set up the watering time on 7 am to on the relay and setr the water pump to push out water and i also set the relay to off back after 36 seconds,then it will water the plants again at 5 pm.but when i upload the code,the relay always on and didnt follow as i set up in the code,the relay also didnt turned on when the time is 7 am and 5 pm.Anyone who knows about this please help me to fix it,i really need to fix it quickly. This is the code:

#include <DS3231.h>
DS3231 rtc(SDA, SCL);
#include <Servo.h>
Servo servo1;
char time;
char d;
int Sec;
int Min;
int Hour;
String Day;

void setup() {
Serial.begin(9600);
pinMode(40, OUTPUT);
pinMode(41, OUTPUT);
servo1.attach(7);

rtc.begin();
rtc.setDOW(WEDNESDAY);
rtc.setTime(13, 59, 45);
rtc.setDate(1, 1, 2014);

time = rtc.getTimeStr();
d = rtc.getDOWStr();

}

void loop() {
{Serial.print("date:");
Serial.print(rtc.getDateStr());
Serial.print(" -- ");
Serial.print("time:");
Serial.println(rtc.getTimeStr());
Serial.print("..");
delay(1000);}

if (Hour == 14 && Min == 0 && (Sec == 0 || Sec == 36)){
servo1.write(45);
delay(2000);
{pinMode(40, HIGH);
pinMode(41, LOW);
delay(8000);}
{pinMode(40, LOW);
pinMode(40, LOW);
delay(2000);}
servo1.write(75);
delay(2000);
{pinMode(40, HIGH);
pinMode(41, LOW);
delay(8000);}
{pinMode(40, LOW);
pinMode(40, LOW);
delay(2000);}
servo1.write(115);
delay(2000);
{pinMode(40, HIGH);
pinMode(41, LOW);
delay(8000);}
{pinMode(40, LOW);
pinMode(40, LOW);
delay(2000);
}
}
else if (Hour == 14 && (Min == 0 && Sec == 37)||(Min == 0 && Sec == 59)) {
servo1.write(0);
pinMode(40, LOW);
pinMode(41, LOW);
}

else if (Hour == 14 && Min == 01 && (Sec == 0)||(Sec == 36)){
servo1.write(45);
delay(2000);
{pinMode(40, HIGH);
pinMode(41, LOW);
delay(8000);}
{pinMode(40, LOW);
pinMode(40, LOW);
delay(2000);}
servo1.write(75);
delay(2000);
{pinMode(40, HIGH);
pinMode(41, LOW);
delay(8000);}
{pinMode(40, LOW);
pinMode(40, LOW);
delay(2000);}
servo1.write(115);
delay(2000);
{pinMode(40, HIGH);
pinMode(41, LOW);
delay(8000);}
{pinMode(40, LOW);
pinMode(40, LOW);
delay(2000);}
delay(10000);}
else if (Hour == 14 && (Min == 1 && Sec == 37)||(Min == 2 && Sec == 0)){
servo1.write(0);
pinMode(40, LOW);
pinMode(41, LOW);

}

}

Are you perhaps using pinMode() when you mean digitalWrite() ?

yeah,pinMode and digitalWrite are same command right?

Yes, of course they're not.
They're not even spelled the same.

Please remember to use code tags when posting code.

so,you guys have any recomendation for me to fix this problem?

Yes, use pinMode when it is appropriate to use pinMode, and use digitalWrite when it is appropriate to use digitalWrite.

And use code tags.