Declare Dates Vector in Abinitio

2.8k Views Asked by At

I know how to declare a vector of integer elements in the package editor. let int[] int_vec;

But how can I declare a vector with date elements and it's in the 'YYYYMMDD' format. I tried this and it has syntax error.

let date[] date_vec;

I have spent some time searching for an example in the Help Library.. but no luck there.

2

There are 2 best solutions below

0
On

You can implement this with the following in the in and out ports of a reformat component:

record
    datetime("YYYYMMDDHH24MISSNNNNN")[delimiter=="\x01"] date_vec = NULL;
    string("\n") str;
end;

and as an example, a transformation to assign values as follows:

/*Reformat operation*/
out::reformat(in)=
begin
    out.*::in.*;
    out.date_vec::generate_dates(in.str);
end;

// This function generates as many timestamps as there are characters in 
the string supplied to the function
out :: generate_dates(str) =
begin
    let int i;
    out::for(i,i<length_of(str)): (datetime("YYYYMMDDHH24MISSNNNNN"))(now());
end;

IN:

NULL,HELLO

OUT:

date_vec.date_vec   str
2021070212223281659 HELLO
2021070212223281662 
2021070212223281662 
2021070212223281662 
2021070212223281662 
0
On

Try the following syntax:

let date("YYYYMMDD")[] date_vec;