Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Error in script

If got a folder with daily updated QVD-files with the scheme QDatei_YYYY_MM_DD.QVD. I would like to combine all of the single file into one big QVD. So I've created a QVD from the existing daily files by conatenating them an store them into a QVD. Now, here comes the problem. For new daily files, I'm trying to read only the latest ones and skip the ones, that are already part of the big QVD.

    for each Datei in filelist('$(vPath)' & 'QDatei*.QVD')

            Let vQVDDate = QvdCreateTime('$(Datei)');

            If $(vQVDDate) > $(vLatestQVDDate) Then

            CONCATENATE ($(vTableName)) LOAD

            ...

            FROM '$(Datei)' (qvd)

                $(vLatestQVDDate) = $(vQVDDate);   

            End If

    Next

With the above code I'm getting the following error message. It seems, that the code interpreter is not able

to evaluate the expressioin date1 > date2.

Fehler in Skriptzeile:

If 09.12.2011 12:15:07 > 08.05.2012 05:00:12 Then

Where is the problem?

Michael

4 Replies
Miguel_Angel_Baeyens

Hi Michael,

As the error suggests, those are not valid numeric values, and strings (literals) cannot be compared with ">" and "<" operators. Well, they can, but returning unexpected results as you see. Try the following instead:

    for each Datei in filelist('$(vPath)' & 'QDatei*.QVD')

            Let vQVDDate = QvdCreateTime('$(Datei)');

            If Date($(vQVDDate)) > Date($(vLatestQVDDate)) Then // Note the Date() function here

            CONCATENATE ($(vTableName)) LOAD

            ...

            FROM '$(Datei)' (qvd)

                $(vLatestQVDDate) = $(vQVDDate);  

            End If

    Next

Hope that helps.

Miguel

Anonymous
Not applicable
Author

Hi Miguel,

thanks for the quick response. Too bad, this was not the solution!

After inserting the Date() functions, I've got the following error message.

Fehler in Skriptzeile:

If Date(09.12.2011 12:15:07) > Date(08.05.2012 05:00:12) Then

Best regards

Michael

Miguel_Angel_Baeyens

Hi Michael,

Is that the default regional/local date format as you see it in the variable DateFormat or TimeStampFormat in the main, first lines of the script? If not, you will need to format them using Date#() and Date(). Consider the following script where I'm loading a non-standard date format:

SET DateFormat='DD/MM/YYYY';

SET TimestampFormat='DD/MM/YYYY h:mm:ss[.fff]';

Data:

LOAD * INLINE [

Date, Value

01.01.2011 10:30, A

01.02.2011 04:32, B

01.03.2011 13:00, C

01.04.2011 17:40, D

01.05.2011 00:20, E

];

Only2Q:

NOCONCATENATE LOAD *

RESIDENT Data

WHERE Date#(Date, 'DD.MM.YYYY hh:mm') > Date#('31.03.2011 23:59', 'DD.MM.YYYY hh:mm'); // Take a look at this

DROP TABLE Data;

I need to use the Date#() function with the input format because according to my global variable DateFormat and TimestampFormat, my dates, to be recognized as such, should be separated by "/" instead of ".". Therefore the use of the function.

Hope that helps.

Miguel

Not applicable
Author

change this

If $(vQVDDate) > $(vLatestQVDDate) Then

to

If '$(vQVDDate)' > '$(vLatestQVDDate)' Then

thats it.

Regards.

Sabine