I am unable to transform Datenum() to a string, I can't figure out what I'm doing wrong, I should appreciate some help from the community. Please, consider the following example:
// In the first exploration I create the following static variable
StaticVarSet("DateVariable", DateNum());
// In the second exploration I call the previous static variable for some calculations
ReferenceDate = StaticVarGet("DateVariable");
// After using ReferenceDate for some calculations, I need to show the date in a column of the exploration report
DateFromReferenceDate = DateTimeConvert(2, DateNum());
Filter = 1;
AddTextColumn(DateFromReferenceDate, "Date from DateNum()");
I know that DateTimeConvert is not the right formula since it will return a number or an array and I would need a string, as Date(), but I have been unable to find the correct way to do it.
@jptrader in your last line you are using an array of datetime so you should change it to:
AddColumn(DateFromReferenceDate, "Date from DateNum()", formatDateTime);
using the specific format required to properly display datetime values.
(Check the AddColumn() reference if you prefer to see your dates in the ISO datetime format).
For other purposes, to convert a single datetime (not an array) to a string you could use either the function DateTimeToStr() or the more flexible DateTimeFormat().