String function not returning date, help!

Back to topics list To post a new topic, please log in or register
avatar
49
Opengates 2015.06.09 05:22
 

Hello Gurus in the house,

I am trying to convert date and time string to function as date and time real time in my ea but keeps giving error 'StrToDate' - wrong parameter count", below are the codes:


extern string        NewsDate         = "09/06/2015"; // Year for the News to be released
extern string        NewsTime         = "12:30";   // Time for the News to be released

string  StrToDate();

 //variables defined
string   DateTime=StringConcatenate(NewsDate," ",NewsTime);
datetime Startdate=StrToDate(DateTime, "dd/mm/yyyy hh:mi"); 

if(TimeCurrent()==Startdate) {
//perform certain tasks
} 


pls check and let me know where I got it wrong.

Thanks in advance

avatar
Moderator
3407
GumRai 2015.06.09 05:33 #
 

You haven't written the function StrToDate()

Maybe you could use StrToTime(), but that uses   "yyyy.mm.dd hh:mi " format

avatar
49
Opengates 2015.06.09 05:55 #
 
GumRai:

You haven't written the function StrToDate()

Maybe you could use StrToTime(), but that uses   "yyyy.mm.dd hh:mi " format

Thanks GumRai, I changed to StrToTime() but it says "no one of the overloads can be applied to the function call", pls what do you think that can mean and what do I do OR how do I write the function StrToDate() to produce the right result? Thanks
avatar
Moderator
3407
GumRai 2015.06.09 07:03 #
 
Opengates:
Thanks GumRai, I changed to StrToTime() but it says "no one of theoverloads can be applied to the function call", pls what do you thinkthat can mean and what do I do OR how do I write the function StrToDate() to produce the right result? Thanks

StrToTime() only uses 1 parameter, if you are using more than 1, you are overloading the function

  extern string        NewsDate         = "2015.06.09"; // Date for the News to be released
  extern string        NewsTime         = "12:30";   // Time for the News to be released

//In your main code

  string   DateTime=StringConcatenate(NewsDate," ",NewsTime);
  datetime Startdate=StrToTime(DateTime);


  if(TimeCurrent()==Startdate)    //Be careful of using == in case of missed ticks
    {
    //perform certain tasks
    }

Change the format for entering the date as above.

Avoid using DateTime to name a string variable, it can be confusing 

 

avatar
49
Opengates 2015.06.09 11:32 #
 
GumRai:

StrToTime() only uses 1 parameter, if you are using more than 1, you are overloading the function

Change the format for entering the date as above.

Avoid using DateTime to name a string variable, it can be confusing 

 

Thanks so much, just as you corrected me, it works fine. You are blessed
avatar
12985
Back to topics list  

To add comments, please log in or register