Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
markgraham123
Specialist
Specialist

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.

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

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) = 😎 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

View solution in original post

4 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

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

markgraham123
Specialist
Specialist
Author

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

Peter_Cammaert
Partner - Champion III
Partner - Champion III

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) = 😎 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
Specialist
Specialist
Author

Thanks Peter!!