Function StrToTime causes error 4051 - page 4

 
WHRoeder:
The mq4 documents have been updated. They are both in mt4. https://docs.mql4.com/convert/StrToTime and https://docs.mql4.com/convert/stringtotime

Yep, but still gives error code 4051 unless using full format ("yyyy.mm.dd hh:mi")
 
RaptorUK:'s workaround
datetime StrToday(string tod){ // "21:45"
  datetime now   = TimeCurrent();
  string   today = TimeToStr(now, TIME_DATE);
  return( StrToTime(today + " " + tod) );
}
 
qjol:

Yep, but still gives error code 4051 unless using full format ("yyyy.mm.dd hh:mi")
Is it reported to ServiceDesk ?
 
angevoyageur:
Is it reported to ServiceDesk ?

i dont think so (it's posted here on B604 or so & now on B610 still need to be fixed)
 
angevoyageur:
Is it reported to ServiceDesk ?

Yes, I was as negative as I could be so I reported it out of spite . . .

Error 4051 again, this time with StrToTime
Errors, MetaTrader 4, Open, Start: 2014.02.12 22:13, #954526

Hi,

StrToTime() generates an error 4051 when just used with a time, for example StrToTime("17:35") if a date and time is used, example: StrToTime("2003.8.12 17:35") there is no error.

This can bee seen with the attached code, run it as an EA and change the input from TimeClose_ = "2003.8.12 21:45 21:45" to TimeClose_ = "21:45"


The help file shows this as an example so it should be valid . . . StrToTime("17:35"); // returns the current date with the given time

Please also note the Russian in the English help file (see below) : [in] Строка в формате "yyyy.mm.dd hh:mi ".

MQL4 Reference / Conversion Functions / StrToTime

StrToTime

Converts string in the format "yyyy.mm.dd hh:mi" to datetime type (the amount of seconds that have passed since 1 Jan., 1970).

datetime StrToTime(
string value // string
);

Parameters

value

[in] Строка в формате "yyyy.mm.dd hh:mi ".

Returned value

Value of datetime type as a number of seconds, passed since 01.01.1970.

Example:

datetime var1,var2,var3;
var1=StrToTime("2003.8.12 17:35");
var2=StrToTime("17:35"); // returns the current date with the given time
var3=StrToTime("2003.8.12"); // returns the date with the midnight time of "00:00"


Attachments:
test.mq4(1.29 KB)
 
This was last Wednesday . . . no reply.
Reason: