Trouble coding dates

 

Using the code below, having trouble with dates & any help appreciated.

If I run the EA as is, then it displays Entry day as 1 (correct) Exit day as 335 (wrong).


Using different strings for entry & exit dates gives various wrong answers,

Using 

EntryDate = "D'01.06.2009'";

ExitDate  = "D'02.06.2009'";

gives both as being 152.


Any help as to what am I doing wrong?


rgds McDirt




extern string  EntryDate  = "D'01.01.2009'"; 

extern string  ExitDate   = "D'31.12.2009'";


int      EntryDay, ExitDay;


int init(){

   EntryDay = TimeDayOfYear(StrToTime(EntryDate));

   ExitDay = TimeDayOfYear(StrToTime(ExitDate));

   return(0);

}


int deinit() {

   return(0);

  }


int start(){

   Comment ("" 

      + "\nEntry Date     : " + EntryDate + " (day " + EntryDay + ")"

      + "\nExit Date        : " + ExitDate + " (day " + ExitDay + ")"

   );

}

Reason: