Exploration - DateTimeFormat function

Hi!
I am stuck since yesterday in dateformat , tried many things but not able to get through .Any help would be really great.

What I am trying :
Create exploration with
1.Custom dateformat
2.Rounding the 'close' to nearest hundred for all Monday's for all Indexes. (This will be later used to add more features - Deriving names of options etc)

Progress so far and issue I am facing:

  1. DateTimeFormat function
    When I add AddColumn DateTime(), it prints all Monday dates , however when I try to convert it to YYYYMonDD format it takes current date(Last column value ).
    I know that DateTimeFormat function doesnt take DateTime() array as parameter , so how can I get this DateTime() array passed for only Monday's ?

  2. Round to hundred
    Done

  3. Filtering Monday
    Done

Exploration_Result

rth = 100 * round( C / 100 );
AddTextColumn( FullName(), "  Full name  ", 77 , colorDefault);
AddColumn((C), "  ClosingPrice  ",1,colorBlack);
AddColumn(rth, "   RTH   ",1,colorBlack);
AddColumn(  dt, "  Datetime  ", formatDateTime );
dt_str = DateTimeFormat(" %Y%b%d ",selectedvalue( DateTime()) );
AddtextColumn(dt_str,"  Date_Str  ", 1, colorBlack);
Filter=(DayOfWeek()==1);

If you would read the manual then you can see that AddColumn's formatDateTime produces date time formated according to your system settings. So if you want different date time format then change system settings. Besides of formatDateTime there is formatDateTimeISO also mentioned in manual. But you want it without "-" and with month abbreviation instead of month number (for whatever reason). So again change system settings then and using formatDateTime.

And DateTimeFormat returns string. You can not convert a numbered array to an array of strings or string containing entire array of numbers being converted. DateTimeFormat expects single DateTime value (or element of array) but not array itself. If you insert array then AB converts to single array element internally.

So if you want to output date time format for entire array using DateTimeFormat function then you would have to iterate (-> looping) and using AddRow. But then your whole exploration output would have to be solely based on Addrow. And AddColumn(s) would serve for initializing columns only. Is that worth the effort just for changing date time format to YYYYMonthDD instead of YYYY-MM-DD? I don't think so.

2 Likes

@fxshrat Thank you for the response.

I did try changing the system time format , the problem with that is , Data feed vendor dont support YYYYMonDD timeformat.
So I had to work around this.

The reason I am trying to do this is to derive the names of the options based on index name.

<Indexname>+<DateinYYYYMonDD>+<RoundedClose>+<CE/PE>