On several places there are comments like the following (https://www.mql5.com/en/forum/688):
datetime t; MqlDateTime mdt; TimeToStruct(t,mdt);
mdt.day += 45; //or mdt.day = 50; //50 days from the beginning of the month //or mdt.hour += 134; //134 hours in the future //or mdt.hour = 1000; //1000 hours from the beginning of the day
This works but gives incorrect results. example: mdt.day -= 50 gives an negative day and not a day one ore two month in the past.
What is MqlDateTime
useful for if not for calculations? and how do you calculate valid dates?
Attached is a indicator that shows the incorrect behavior of the above method
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
How to Calculate with date and times?
On several places there are comments like the following (https://www.mql5.com/en/forum/688):
datetime t;
MqlDateTime mdt;
TimeToStruct(t,mdt);
mdt.day += 45;
//or mdt.day = 50; //50 days from the beginning of the month
//or mdt.hour += 134; //134 hours in the future
//or mdt.hour = 1000; //1000 hours from the beginning of the day
This works but gives incorrect results. example:
mdt.day -= 50 gives an negative day and not a day one ore two month in the past.
What is MqlDateTime useful for if not for calculations?
and how do you calculate valid dates?
Attached is a indicator that shows the incorrect behavior of the above method
regards and thanks for your help
Daniel