DateTime variable conversion in double/long

 

Good morning/evening,


After seeking all the parts of the documentation without answers, I come to you with this question :

I am calculating time elapsed during now and a fixed date.

datetime fixeddate;
datetime timetocalc;

timetocalc=TimeCurrent()-fixeddate;

Now I would like to have timetocalc as a long or double in number of second.

But when I write Print(timetocalc); program return 1970.01.03 05:10:0 (For 2 days 5 hours and 10 minutes)

I have tried StringTotime(timetocalc) without succes.

How convert 1970.01.03 05:10:00 in a long/double value equal to the number of second since January 1, 1970 ?

Thanks a lot.


Pierre

 
A difference of datetime is not a datetime, declare your timetocalc as int or long.
 
Hi  ..it is very helpful to understand mqldatetime structure   ...then You will be able to do much more then simple calculations 

https://www.mql5.com/en/docs/constants/structures/mqldatetime

Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Date Type Structure
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Date Type Structure
  • www.mql5.com
Constants, Enumerations and Structures / Data Structures / Date Type Structure - Reference on algorithmic/automated trading language for MetaTrader 5
 
I would like to thanks Alain for his continuous support. (Also Marcin of course but Alain answer has resolved my issue).

The fact to declare timetocalc as long has definitively resolved all the issues I had last night.

(Vive la belgique !)

Pierre
 
Pierre DELAHAYE:
I would like to thanks Alain for his continuous support. (Also Marcin of course but Alain answer has resolved my issue).

The fact to declare timetocalc as long has definitively resolved all the issues I had last night.

(Vive la belgique !)

Pierre
Thanks. :-)