How to use MqlDateTime? (day_of_week,hour)

 

Any idea to use this function?

in MQL5 i use this

         MqlDateTime hari,jam ;

         Print("Day of Week =",hari.day_of_week);
         Print("Hour =",jam.hour);

the result

 Day of Week = 0

 Hour = 0

Actually i want to coding similar like this in MQL4, like this

  Print("Day of Week =",DayOfWeek()); 

 

help me? 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Structure of the Date Type
  • www.mql5.com
Standard Constants, Enumerations and Structures / Data Structures / Structure of the Date Type - Documentation on MQL5
 
haidzatul posted  :

Any idea to use this function?

in MQL5 i use this

         MqlDateTime hari,jam ;

         Print("Day of Week =",hari.day_of_week);
         Print("Hour =",jam.hour);

the result

 Day of Week = 0

 Hour = 0

Actually i want to coding similar like this in MQL4, like this

  Print("Day of Week =",DayOfWeek()); 

 

help me? 

 

Your MqlDateTime line only declares the structure and you need another command such as TimeCurrent to populate it.  This is documented in the MQL5 editor help.

MqlDateTime hari;
TimeCurrent(hari);

Print("Day of Week =",hari.day_of_week);
Print("Hour =",hari.hour);

Paul

 

 
phampton:

Your MqlDateTime line only declares the structure and you need another command such as TimeCurrent to populate it.  This is documented in the MQL5 editor help.

Paul

 

it's work

Thank Paul 

Reason: