function DatiElabRainLink = LastElab_bisRL(conn,NodoRainLink,rRL,datainiRL,...
    tempoiniRL,IDcentralina,DTcatena,FileName)

NRainLink = cell2mat(NodoRainLink(:,2));
NodeType = 'Rain Link';
ii = 1; % contatore
col = 4; % contatore colonne
while ii <= rRL
    ini_col = col-3;
    nN = num2str(NRainLink(ii,1));
    % Scarico di dati di spostamenti
    comando = ['select EventDate, EventTime, ZShift, Z from ElabDataView where EventDate = ''' ...
        datainiRL ''' and  EventTime >= ''' tempoiniRL ''' and UnitName = ''' IDcentralina ''' and ToolNameID = '''...
        DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
    curs = exec(conn,comando);
    curs = fetch(curs);
    DATnodoRLd = curs.Data;
    % Scarico di dati di spostamenti
    comando = ['select EventDate, EventTime, ZShift, Z from ElabDataView where EventDate > ''' ...
        datainiRL ''' and  UnitName = ''' IDcentralina ''' and ToolNameID = '''...
        DTcatena ''' and NodeType = ''' NodeType ''' and NodeNum = ''' nN ''' '];
    curs = exec(conn,comando);
    curs = fetch(curs);
    DATnodoRL = curs.Data; 
    [~,c1] = size(DATnodoRL);
    [~,c2] = size(DATnodoRLd);
    if c1==c2
        DATnodoRL = [DATnodoRLd; DATnodoRL];
    elseif c1 < c2 % solo giorno di riferimento
        DATnodoRL = DATnodoRLd;
    end
    DatiElabRainLink(:,ini_col:col) = DATnodoRL(:,:);
    col = col+4;
    ii = ii+1;
end

text = 'LastElab_bisRL function worked correctly for Rain Link';
fileID = fopen(FileName,'a');
fmt = '%s \r';
fprintf(fileID,fmt,text);
fclose(fileID);
end