need help with datetime values

 
hi, i need help to change parts of some datetime value, with another variable, it's possible to do that?
//+------------------------------------------------------------------+
//|                                                test.mq4 |
extern datetime time= D'2017.11.05 0:01:00';
int a=10;


int start ()

{

time= D'2017.11."a" 0:01:00'-- Question- it is possible to place 'a' int value on this time data type in some way. 
so changing 05 to 10, thanks a lot



return (0);
};
 
mrluck1:
hi, i need help to change parts of some datetime value, with another variable, it's possible to do that?


//+------------------------------------------------------------------+
//|
                                                test.mq4 |
extern datetime time= D'2017.11.05 0:01:00';
int a=10;


int start ()

{

// Method 1

MqlDateTime Mtime;
TimeToStruct(time, Mtime);
Mtime.day = a;
time = StructToTime(Mtime);

Print("Method 1:  time = " + TimeToString(time ,TIME_DATE|TIME_SECONDS));

// Method 2

string stime = StringFormat("2017.11.%02d 00:01:00", a);
time= StringToTime(stime);

Print("Method 2:  stime = " + stime + ", time = " + TimeToString(time ,TIME_DATE|TIME_SECONDS));


return (0);
};


I recommend Method 1.  Regards.

 

thanks a lot  for your help man, i'll use method 2 although, not used to OOP, and method 2 is easier to understand, have a nice day

 
mrluck1:

thanks a lot  for your help man, i'll use method 2 although, not used to OOP, and method 2 is easier to understand, have a nice day

You are welcome.  Have a nice day, too.
Reason: