Wrong datetime computing?

 

There are  376565 days between 1970.01.01 00:00:00 and 3000.12.31 23:59:59. so the number of seconds is 376565*24*60*60-1=32535215999.

but computing in MQL5,

   datetime AA=D'3000.12.31 23:59:59';
   printf(TimeToString(AA,TIME_DATE|TIME_SECONDS));
   printf("%u",AA);

The output result is:

2013.12.08 00:32:05.924    aaa (EURUSD,M5)    2470444927
2013.12.08 00:32:05.924    aaa (EURUSD,M5)    3000.12.31 23:59:59

 
kwang1:

There are  376565 days between 1970.01.01 00:00:00 and 3000.12.31 23:59:59. so the number of seconds is 376565*24*60*60-1=32535215999.

but computing in MQL5,

The output result is:

2013.12.08 00:32:05.924    aaa (EURUSD,M5)    2470444927
2013.12.08 00:32:05.924    aaa (EURUSD,M5)    3000.12.31 23:59:59

Why are you thinking datetime is an unsigned int ? Documentation said it's an 8 bytes value, so it's a long not an int.

   printf("As number of seconds %llu",AA);

Result:

2013.12.07 18:14:07    Test (EURUSD,H1)    As number of seconds 32535215999

 
kwang1:

There are  376565 days between 1970.01.01 00:00:00 and 3000.12.31 23:59:59. so the number of seconds is 376565*24*60*60-1=32535215999.

but computing in MQL5,

The output result is:

2013.12.08 00:32:05.924    aaa (EURUSD,M5)    2470444927
2013.12.08 00:32:05.924    aaa (EURUSD,M5)    3000.12.31 23:59:59

Try . . . 

printf("%I64",AA);

 . . . for an unsigned long

 
RaptorUK:

Try . . . 

 . . . for an unsigned long

  • "%I64" isn't a valid format. See documentation.
  • I64 isn't specific to unsigned, it's available for signed also.
  • You have to use "%I64u" or "%llu" as I previously posted.
 
Thank you very much.....
Reason: