B-Abbasi
B-Abbasi

Reputation: 823

Using Where cluase while loading data in Qlikview From Database

Need help using Where cluase while loading data in Qlikview From Database

Following is the script that executes perfectly

    LET vCutOffDate  = MakeDate(2015,10,14);
    LOAD `CITY_NM`,
        `CST_NM`,
        `CST_TP`,
        `DATA_DATE`
    ;
    SQL SELECT `CITY_NM`,
        `CST_NM`,
        `CST_TP`,
        `DATA_DATE`
    FROM TEST.`ABC`
    ;

When I add "where" clause it shows weird behavior for Greater than(>),Less Than(<) And Equal to(=) operators, Script Does not fetch any data for < and = operator whereas fetches all the data when I use > operator.

Below is the final script I am trying along with where clause

    LET vCutOffDate  = MakeDate(2015,10,14);
    LOAD `CITY_NM`,
        `CST_NM`,
        `CST_TP`,
        `DATA_DATE`
    ;
    SQL SELECT `CITY_NM`,
        `CST_NM`,
        `CST_TP`,
        `DATA_DATE`
    FROM TEST.`ABC`
    WHERE (`DATA_DATE`<'$(vCutOffDate)')
    ;

Following are the date values I see If I view DATA_DATE by Select_Fields option

    10/11/2015 0:00
    10/14/2015 0:00
    10/18/2015 0:00
    10/31/2015 0:00

Upvotes: 1

Views: 2142

Answers (1)

Arno
Arno

Reputation: 26

I suppose the problem lies in the date formatting. It depends on the database, which date format is needed, but this should work.

LET vCutOffDate  = TimeStamp(MakeDate(2015,10,14), 'YYYYMMDD');
LOAD `CITY_NM`,
    `CST_NM`,
    `CST_TP`,
    `DATA_DATE`
;
SQL SELECT `CITY_NM`,
    `CST_NM`,
    `CST_TP`,
    `DATA_DATE`
FROM TEST.`ABC`
WHERE (`DATA_DATE`<'$(vCutOffDate)')
;

Upvotes: 1

Related Questions