datalogger for counter sensor with RTC HELP!

I think that the best thing, at this point, is for you to post all of your code.

im sorry for the terrible names, i changed it a little bit i hope it will be more understandable.

//Program by Jeremy Blum
//www.jeremyblum.com
//SD Card Demonstration
//Some code from public domain work by Tom Igoe
//Assisted by Inigo D. Villanueva III
//Edited by Ignacio D. Villanueva III
//For thesis purpose entitled "
//Thesis members: James Santiago. Belen Cruz. Franzes Francisco, Kaye Agut

#include <SD.h>         //SD Card Library

//SPI SD Card Pins
//MOSI = Pin 11
//MISO = Pin 12
//SCLK = PIN 13
int CS_pin = 10;
int pow_pin = 8;

// this constant won't change:
const int  buttonPinA = 3;    // the pin that the pushbutton is attached to
const int  buttonPinB = 5;

// Variables will change:
int CurrentNumberofBeesA = 0;   // counter for the number of button presses
int ActualStateofCounterA = 0;         // state of the button (Either HIGH or LOW)
int PreviousStateofCounterA = 0;     // previous state of the button (Either HIGH or LOW)
int CurrentNumberofBeesB = 0;   // counter for the number of button presses
int ActualStateofCounterB = 0;         // state of the button (Either HIGH or LOW)
int PreviousStateofCounterB= 0;     // previous state of the button (Either HIGH or LOW)


long lastEvent= 0; // The last time a bee has entered the feeding station
long interval= 300; // The debounce time



void setup() {

  Serial.begin(9600);
  Serial.println("Initializing Card");
  //CS Pin is an output
  pinMode(CS_pin, OUTPUT);

  //SD Card will Draw Power from Pin 8, so set it high
  pinMode(pow_pin, OUTPUT);  
  digitalWrite(pow_pin, HIGH);

  //Initialize Card
  if (!SD.begin(CS_pin))
  {
    Serial.println("Card Failure");
    return;
  }
  Serial.println("Card Ready");

  // initialize the button pin as a input:
  pinMode(buttonPinA, INPUT);
  pinMode(buttonPinB, INPUT);

  // initialize serial communication:
  Serial.begin(9600);
}


void loop() {
  // read the pushbutton input pin:
  ActualStateofCounterA= digitalRead(buttonPinA);
  ActualStateofCounterB = digitalRead(buttonPinB);

  // compare the buttonState to its previous state
  if ((ActualStateofCounterA != PreviousStateofCounterA ) || (ActualStateofCounterB != PreviousStateofCounterB))
  {
    // if the state has changed, increment the counter
    if (ActualStateofCounterA == HIGH && millis() - lastEvent > interval)// Ignore this reading if it is too close to the last one
    {
      lastEvent= millis(); // a bee can be recorded) 
      // if the current state is HIGH then the button
      // wend from off to on:

      CurrentNumberofBeesA++;
      Serial.println("Bees are being detected entering Feeding Station A");
      Serial.print("number of bees that entered Feeding Station A:  ");
      Serial.println(CurrentNumberofBeesA);

    }
    {    
      // if the state has changed, increment the counter
      if (ActualStateofCounterB == HIGH && millis() - lastEvent > interval)// Ignore this reading if it is too close to the last one
      {
        lastEvent= millis(); // a bee can be recorded) 
        // if the current state is HIGH then the button
        // wend from off to on:
      }  
      CurrentNumberofBeesB++;
      Serial.println("Bees are being detected entering Feeding Station B");
      Serial.print("number of bees that entered Feeding Station B:  ");
      Serial.println(CurrentNumberofBeesB);
    }




    //Write Log File Header
    File logFile = SD.open("DATALOG.csv", FILE_WRITE);
    if (logFile)


    {

      if(ActualStateofCounterA != PreviousStateofCounterA)

        logFile.print(CurrentNumberofBeesA);
      logFile.print(", ");
      logFile.println(CurrentNumberofBeesB); 
      logFile.close();

      Serial.print(CurrentNumberofBeesA);
      Serial.print(", ");
      Serial.println(CurrentNumberofBeesB);

    }
    else

    {
      Serial.println("LogFile cannot be opened");

    }

    CurrentNumberofBeesA= ActualStateofCounterA;
    CurrentNumberofBeesB= ActualStateofCounterB;


  }

}