Download MetaTrader 5
To add comments, please log in or register
Do you have idle PCs? Connect them to MQL5 Cloud Network and earn money!
KoT 009
44112
KoT 009 2013.06.06 08:46 
How to add or subtract days or minutes from a MQL5 Time Structure ?
Simon Gniadkowski
Moderator
17975
Simon Gniadkowski 2013.06.06 09:14  
chandra100:
How to add or subtract days or minutes from a MQL5 Time Structure ?
Convert to seconds then add or subtract . . .  do you understand what a datetime type variable is ?  look it up.
KoT 009
44112
KoT 009 2013.06.06 09:32  
RaptorUK:
Convert to seconds then add or subtract . . .  do you understand what a datetime type variable is ?  look it up.

I dont think ur idea will work.

Simon Gniadkowski
Moderator
17975
Simon Gniadkowski 2013.06.06 10:11  
chandra100:

I dont think ur idea will work.

Maybe I misunderstood your question then,  why will it not work ?
KoT 009
44112
KoT 009 2013.06.06 10:57  
,RaptorUK:
Maybe I misunderstood your question then,  why will it not work ?

Assume the present date is Feb 28 and time is 23:00.    

If I like to add 2 hours, it has to change all the three of hour part , day part and month part of datetime strucrure.

Leap year factor should also be taken into account.

converting into seconds won't do any purpose. 

Simon Gniadkowski
Moderator
17975
Simon Gniadkowski 2013.06.06 11:20  
chandra100:

Assume the present date is Feb 28 and time is 23:00.    

If I like to add 2 hours, it has to change all the three of hour part , day part and month part of datetime strucrure.

Leap year factor should also be taken into account.

converting into seconds won't do any purpose. 

OK,  I did understand your question correctly,  if you have Feb 28th 23:00 saved in a datetime variable and you want to add 2 hours all you do is add  2 * 60 * 60 to the variable.  You don't need to be concerned with leap years.  when you use TimeToString() with this variable and Print() it you will see the correct date and time . . .
Dua Yong Rew
5207
Dua Yong Rew 2013.06.06 12:17  

https://www.mql5.com/en/forum/7986

I asked something similar before 

ObjectCreate
ObjectCreate
  • www.mql5.com
I have the codes to draw a horizontal trend line.
Alain Verleyen
Moderator
29604
Alain Verleyen 2013.06.06 12:29  
KoT 009
44112
KoT 009 2013.06.06 12:40  
angevoyageur:
See this article.
That was fine.
/
To add comments, please log in or register