# Date and Time Arithmetic

Register as a seller and start making profit!
44107
2013.06.06 08:46
How to add or subtract days or minutes from a MQL5 Time Structure ?
Moderator
18001
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.
44107
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.

Moderator
18001
2013.06.06 10:11
chandra100:

I dont think ur idea will work.

Maybe I misunderstood your question then,  why will it not work ?
44107
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.

Moderator
18001
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 . . .
5424
2013.06.06 12:17

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