function [DatiElabTiltLink,DatiElabTiltLinkHR,DatiElabTiltLinkH,DatiElabTiltLinkHRH,...
    DatiElabRainLink,DatiElabInPlaceLink,DatiElabInPlaceLinkHR,DatiElabSnowLink] = checkdata(...
    yesTL,yesTLHR,yesTLH,yesTLHRH,yesRL,yesSL,yesIPL,yesIPLHR,...
    DatiElabTiltLink,DatiElabTiltLinkHR,DatiElabTiltLinkH,DatiElabTiltLinkHRH,...
    DatiElabRainLink,DatiElabInPlaceLink,DatiElabInPlaceLinkHR,DatiElabSnowLink,...
    datainiTL,tempoiniTL,datainiTLHR,tempoiniTLHR,datainiTLH,tempoiniTLH,...
    datainiTLHRH,tempoiniTLHRH,datainiRL,tempoiniRL,datainiIPL,tempoiniIPL,...
    datainiIPLHR,tempoiniIPLHR,datainiSL,tempoiniSL,rTL,rTLHR,rTLH,rTLHRH,rRL,rSL,rIPL,rIPLHR,...
    NodoTiltLink,NodoTiltLinkHR,NodoTiltLinkH,NodoTiltLinkHRH,...
    NodoRainLink,NodoInPlaceLink,NodoInPlaceLinkHR,NodoSnowLink,...
    NuovoZeroTL,NuovoZeroTLHR,NuovoZeroTLH,NuovoZeroTLHRH,NuovoZeroRL,NuovoZeroSL,...
    NuovoZeroIPL,NuovoZeroIPLHR,IDcentralina,DTcatena,conn,FileName)

%% Tilt Link V
if yesTL == 1 
    if NuovoZeroTL == 1
        data1 = datenum([char(DatiElabTiltLink(1,1)) ' ' char(DatiElabTiltLink(1,2))]); % Prima data elaborata
        data2 = datenum([datainiTL(1,1:10),' ',tempoiniTL]); % Prima data grezza
        if data2 ~= data1 % devo riscaricare l'ultimo dato elaborato a partire da dataini
            datainiTL = datestr(data2,'yyyy-mm-dd');
            tempoiniTL = datestr(data2,'HH:MM:SS');
            DatiElabTiltLink = LastElab_bisTL(conn,NodoTiltLink,rTL,datainiTL,...
                tempoiniTL,IDcentralina,DTcatena,FileName);
        end
    end
end

%% Tilt Link HR V
if yesTLHR == 1
    if NuovoZeroTLHR == 1
        data1 = datenum([char(DatiElabTiltLinkHR(1,1)) ' ' char(DatiElabTiltLinkHR(1,2))]);
        data2 = datenum([datainiTLHR(1,1:10),' ',tempoiniTLHR]); % Prima data grezza
        if data2 ~= data1 % devo riscaricare l'ultimo dato elaborato a partire da dataini
            datainiTLHR = datestr(data2,'yyyy-mm-dd');
            tempoiniTLHR = datestr(data2,'HH:MM:SS');
            DatiElabTiltLinkHR = LastElab_bisTLHR(conn,NodoTiltLinkHR,rTLHR,...
                datainiTLHR,tempoiniTLHR,IDcentralina,DTcatena,FileName);
        end
    end
end

%% Tilt Link H
if yesTLH == 1
    if NuovoZeroTLH == 1
        data1 = datenum([char(DatiElabTiltLinkH(1,1)) ' ' char(DatiElabTiltLinkH(1,2))]);
        data2 = datenum([datainiTLH(1,1:10),' ',tempoiniTLH]); % Prima data grezza
        if data2 ~= data1 % devo riscaricare l'ultimo dato elaborato a partire da dataini
            datainiTLH = datestr(data2,'yyyy-mm-dd');
            tempoiniTLH = datestr(data2,'HH:MM:SS');
            DatiElabTiltLinkH = LastElab_bisTLH(conn,NodoTiltLinkH,rTLH,datainiTLH,...
                tempoiniTLH,IDcentralina,DTcatena,FileName);
        end
    end
end

%% Tilt Link HR H
if yesTLHRH == 1
    if NuovoZeroTLHRH == 1
        data1 = datenum([char(DatiElabTiltLinkHRH(1,1)) ' ' char(DatiElabTiltLinkHRH(1,2))]);
        data2 = datenum([datainiTLHRH(1,1:10),' ',tempoiniTLHRH]); % Prima data grezza
        if data2 ~= data1 % devo riscaricare l'ultimo dato elaborato a partire da dataini
            datainiTLHRH = datestr(data2,'yyyy-mm-dd');
            tempoiniTLHRH = datestr(data2,'HH:MM:SS');
            DatiElabTiltLinkHRH = LastElab_bisTLHRH(conn,NodoTiltLinkHRH,rTLHRH,...
                datainiTLHRH,tempoiniTLHRH,IDcentralina,DTcatena,FileName);
        end
    end
end

%% Rain Link
if yesRL == 1
    if NuovoZeroRL == 1
        data1 = datenum([char(DatiElabRainLink(1,1)) ' ' char(DatiElabRainLink(1,2))]);
        data2 = datenum([datainiRL(1,1:10),' ',tempoiniRL]); % Prima data grezza
        if data2 ~= data1 % devo riscaricare l'ultimo dato elaborato a partire da dataini
            datainiRL = datestr(data2,'yyyy-mm-dd');
            tempoiniRL = datestr(data2,'HH:MM:SS');
            DatiElabRainLink = LastElab_bisRL(conn,NodoRainLink,rRL,datainiRL,tempoiniRL,...
                IDcentralina,DTcatena,FileName);
        end
    end
end

%% Snow Link
if yesSL == 1
    if NuovoZeroSL == 1
        data1 = datenum([char(DatiElabSnowLink(1,1)) ' ' char(DatiElabSnowLink(1,2))]);
        data2 = datenum([datainiSL(1,1:10),' ',tempoiniSL]); % Prima data grezza
        if data2 ~= data1 % devo riscaricare l'ultimo dato elaborato a partire da dataini
            datainiSL = datestr(data2,'yyyy-mm-dd');
            tempoiniSL = datestr(data2,'HH:MM:SS');
            DatiElabSnowLink = LastElab_bisSL(conn,NodoSnowLink,rSL,datainiSL,tempoiniSL,...
                IDcentralina,DTcatena,FileName);
        end
    end
end

%% In Place Link
if yesIPL == 1 
    if NuovoZeroIPL == 1
        data1 = datenum([char(DatiElabInPlaceLink(1,1)) ' ' char(DatiElabInPlaceLink(1,2))]);
        data2 = datenum([datainiIPL(1,1:10),' ',tempoiniIPL]); % Prima data grezza
        if data2 ~= data1 % devo riscaricare l'ultimo dato elaborato a partire da dataini
            datainiIPL = datestr(data2,'yyyy-mm-dd');
            tempoiniIPL = datestr(data2,'HH:MM:SS');
            DatiElabInPlaceLink = LastElab_bisIPL(conn,NodoInPlaceLink,rIPL,...
                datainiIPL,tempoiniIPL,IDcentralina,DTcatena,FileName);
        end
    end
end

%% In Place Link HR
if yesIPLHR == 1
    if NuovoZeroIPLHR == 1
        data1 = datenum([char(DatiElabInPlaceLinkHR(1,1)) ' ' char(DatiElabInPlaceLinkHR(1,2))]);
        data2 = datenum([datainiIPLHR(1,1:10),' ',tempoiniIPLHR]); % Prima data grezza
        if data2 ~= data1 % devo riscaricare l'ultimo dato elaborato a partire da dataini
            datainiIPLHR = datestr(data2,'yyyy-mm-dd');
            tempoiniIPLHR = datestr(data2,'HH:MM:SS');
            DatiElabInPlaceLinkHR = LastElab_bisIPLHR(conn,NodoInPlaceLinkHR,rIPLHR,...
                datainiIPLHR,tempoiniIPLHR,IDcentralina,DTcatena,FileName);
        end
    end
end

text = 'checkdata function worked correctly';
fileID = fopen(FileName,'a');
fmt = '%s \r';
fprintf(fileID,fmt,text);
fclose(fileID);

end