Transforming TimeCurrent results to other softwares

 

I created a script to write a file with some fields, and one of them is TimeCurrent(). But the problem is that it is returning to me a number that I cannot translate to date in other programs (e.g. R, Excel, Calc OpenOffice).

 This a sample of the numbers that it returns:

1422013200
1422013801
1422014100
1422014401
1422014701

 

And these are some outputs from Google Spreadsheets and Open Office. Neither of them represent the true date which shoud been (jan,21,15 or jan,20,15) 

Google Spreadsheet date format

1/1/1970
1/1/1970
1/1/1970
1/1/1970
1/1/1970

Calc Open Office date format

11/25/15
07/18/17
05/13/18
03/10/19
01/04/20

 This is my code: 

if (OrderSelect(tkt, SELECT_BY_TICKET) == true) {
          filehandle=FileOpen("opens.csv",FILE_CSV|FILE_READ|FILE_WRITE, ";");
          if(filehandle!=INVALID_HANDLE)
          {
            if(FileSeek(filehandle, 0, SEEK_END)) {
              
              Print("appending to file");
              
              FileWrite(filehandle,
              ticket,
              TimeCurrent(),
              MagicNumber,
              OrderType(),
              Symbol(),
              OrderOpenPrice(),
              EnumToString(ENUM_TIMEFRAMES(_Period)));
              
              FileClose(filehandle);
              data_return=1;
                               
            }
          }

            
 
filipefr:

I created a script to write a file with some fields, and one of them is TimeCurrent(). But the problem is that it is returning to me a number that I cannot translate to date in other programs (e.g. R, Excel, Calc OpenOffice).

 This a sample of the numbers that it returns:

 

1422013200
1422013801
1422014100
1422014401
1422014701

 

I think that you are probably looking at the value for ticket here, not TimeCurrent()
 

This is the list of fields in my file:

2009475830      1422015001      12345   1       EURUSD  1.12239 PERIOD_M5
2009476703      1422015300      12345   1       EURUSD  1.12336 PERIOD_M5
2009477514      1422015610      12345   1       EURUSD  1.12341 PERIOD_M5

 

 From my code, timecurrent() should be the second column, right? 

 

My Excel is quite old now so not sure if there is a difference with newer versions.

But your code that you posted will not separate the data into different columns.

It will if you change the delimiter to a "," 

filehandle=FileOpen("opens.csv",FILE_CSV|FILE_READ|FILE_WRITE, ",");

Also, TimeCurrent()is output to file as a string, not a number , so how is it appearing in your file as a number?

It should be output as  2015.01.23 12:10:01

 

This makes me think that the code that you have posted is not the code that you have used.

 
GumRai:

My Excel is quite old now so not sure if there is a difference with newer versions.

But your code that you posted will not separate the data into different columns.

It will if you change the delimiter to a ","

Doesn't matter, it depends of regional settings.

Also, TimeCurrent()is output to file as a string, not a number , so how is it appearing in your file as a number?

It should be output as  2015.01.23 12:10:01

Remove #property strict, and it will write a number. Which is also the answer to OP question
 

filipefr: I created a script to write a file with some fields, and one of them is TimeCurrent(). But the problem is that it is returning to me a number that I cannot translate to date in other programs (e.g. R, Excel, Calc OpenOffice).

This a sample of the numbers that it returns:

1422013200
1422013801
1422014100
1422014401
1422014701
  1. 1422014100 is Fri, 23 Jan 2015 11:55:00 GMT according to Online Conversion - Unix time conversion
  2. So stop outputting a number. Convert the datetime to a string that the other programs can read.
 
angevoyageur:

Remove #property strict, and it will write a number. Which is also the answer to OP question


Yet another example of the documentation being incomplete!

Numbers of the datetime type are displayed as "YYYY.MM.DD HH:MI:SS". 

Nowhere does it state that it will display a number if #property strict is removed. 

 
GumRai:

Yet another example of the documentation being incomplete!

Numbers of the datetime type are displayed as "YYYY.MM.DD HH:MI:SS". 

Nowhere does it state that it will display a number if #property strict is removed. 

You are certainly right about the documentation, but this is how datetime where "displayed" before build 6xx, and not using #property strict means you will use the "old" compiler.

Reason: