Problem in operation with a date and array at mql5 language

 

I would compute a variable datetime and a type int, like 2009.01.06 + 3 (this is easy in Excel). Can you help me, how to procede the good script ? 

 
RDfx:

I would compute a variable datetime and a type int, like 2009.01.0e 6 + 3 (this is easy in Excel). Can you help me, how to procede the good script ? 

1. Correct me if I'm wrong, that is  3 days after Jan 6th, 2009, right ? Not 3 hours, or 3 months .

2. Datetime type is actually an integer. Here's what the doc says (https://www.mql5.com/en/docs/basis/types/integer/datetime) , that datetime is "intended for storing the date and time as the number of seconds elapsed since January 01, 1970"  .Read the one that I highlighted.

That mean to add just one day to a datetime is the same with adding 86400 to a datetime. That's because the number of second that elapsed in a day is equal with 86400 seconds (= 24 hours * 60 minutes * 60 seconds).  

Just make sure you write the datetime format correctly.

  datetime today = 0;
  int a_day = 86400;
  
  a_day = today + a_day;
  
  Alert (TimeToString (a_day, TIME_DATE| TIME_SECONDS));
Documentation on MQL5: Language Basics / Data Types
Documentation on MQL5: Language Basics / Data Types
  • www.mql5.com
Language Basics / Data Types - Documentation on MQL5