Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

markgraham123
Contributor II

Loading multiple qvds which have time stamp greater than given date

Hi all,

I'm trying to load all qvds in the given folder which have timestamp greater than the date i give:

Example


If my date given is 20160915, then i wanna load all qvds greater than 20160915 (this is the time stamp in the last 8 characters of the filename).

Any help is highly appreciated.

Tags (1)
1 Solution

Accepted Solutions

Re: Loading multiple qvds which have time stamp greater than given date

Still have to run a test on this, but you'll get the idea:

LET vPath = 'C:\Temp\';

LET vCutoffDate = '20160915';

LET vCutoffNum = num(MakeDate(left(vCutoffDate, 4), mid(vCutoffDate, 5, 2), right(vCutoffDate, 2)));

FOR EACH vFilePath in FileList('$(vPath)\*.QVD')

  LET vFileDate = right(mid(vFilePath, index(vFilePath, '\', -1)+1,

                                       index(vFilePath, '.', -1) - index(vFilePath, '\', -1) -1), 8);

  IF (len(vFileDate) = 8) and (len(Purgechar(vFileDate, '0123456789')) = 0) THEN

    IF MakeDate(left(vFileDate, 4), mid(vFileDate, 5, 2), right(vFileDate, 2)) > vCutoffNum THEN

      ResidentTable:

      LOAD * FROM [$(vFilePath)] (qvd);

    END IF

  END IF

NEXT


[Edit] Made a few corrections to make it work allright

4 Replies

Re: Loading multiple qvds which have time stamp greater than given date

Do these QVDs have the same layout, e.g. should they be concatenated into the same Resident table?

markgraham123
Contributor II

Re: Loading multiple qvds which have time stamp greater than given date

Yes sir. This is for concatenation into the resident table.

Re: Loading multiple qvds which have time stamp greater than given date

Still have to run a test on this, but you'll get the idea:

LET vPath = 'C:\Temp\';

LET vCutoffDate = '20160915';

LET vCutoffNum = num(MakeDate(left(vCutoffDate, 4), mid(vCutoffDate, 5, 2), right(vCutoffDate, 2)));

FOR EACH vFilePath in FileList('$(vPath)\*.QVD')

  LET vFileDate = right(mid(vFilePath, index(vFilePath, '\', -1)+1,

                                       index(vFilePath, '.', -1) - index(vFilePath, '\', -1) -1), 8);

  IF (len(vFileDate) = 8) and (len(Purgechar(vFileDate, '0123456789')) = 0) THEN

    IF MakeDate(left(vFileDate, 4), mid(vFileDate, 5, 2), right(vFileDate, 2)) > vCutoffNum THEN

      ResidentTable:

      LOAD * FROM [$(vFilePath)] (qvd);

    END IF

  END IF

NEXT


[Edit] Made a few corrections to make it work allright

markgraham123
Contributor II

Re: Loading multiple qvds which have time stamp greater than given date

Thanks Peter!!

Community Browser