[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] How To Get Two Digit Year In Exploration



PureBytes Links

Trading Reference Links

1) The following exploration works ok:

Filter = 1;
SetOption("NoDefaultColumns", True);
AddTextColumn(Name(), "Ticker");
AddColumn( DateTime(), "Date&Time", formatDateTime );
AddColumn( Close, "Close", 1.4 );
AddColumn( Volume, "Volume", 1.0 );

2) Now if you try to get two-digit year instead of four-digit year the formula returns an error (the date format on my computer is set to yyyy-mm-dd):

/***START***/

Filter = 1;

yy = StrMid(DateTime(),2,2); //start=char#2 (zero based), length=2 char
mm = StrMid(DateTime(),5,2);
dd = StrMid(DateTime(),8,2);

SetOption("NoDefaultColumns", True);
AddTextColumn(Name(), "Ticker");
AddColumn( DateTime(), "Date&Time", formatDateTime );
AddTextColumn(yy+mm+dd, "yymmdd");

AddColumn( Close, "Close", 1.4 );
AddColumn( Volume, "Volume", 1.0 );

/***END***/

The solution might be to place DateTimeToStr() or StrToDateTime() somewhere there. As a non-programmer I still can't get the feel for all those strings, numbers, arrays, etc.