Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
dmxmikey
Creator
Creator

Where clause

I have below script and need to filter data where the field act-date is <= to today and was wondering how to do that.

Conprice:

SQL SELECT "act-date",

   

FROM price;

20 Replies
neelamsaroha157
Specialist II
Specialist II

Try this:

SQL SELECT "act-date"

FROM price

where [act-date] <= CURRENT_TIMESTAMP

;

dmxmikey
Creator
Creator
Author

I have tried the below but get this error

Syntax error in SQL statement at or about "[act-date] <= num(Today())" (10713)

SQL SELECT "act-date"

FROM price

where [act-date] <= num(Today());

lcontezini
Partner - Creator
Partner - Creator

The date format for "today()" must be the same as [act-date]. I'd suggest you import [act-date] with no filter in order to check the format.


Then you can use it in the where clause with the format you want, maybe like date(today(), 'YYYYMMDD'), or something like this.

neelamsaroha157
Specialist II
Specialist II

instead of num(Today()), use CURRENT_TIMESTAMP if your date format is in timestamp or use GETDATE() if you format is Date.

As you are using direct SQL query instead of Load statement you need to use the SQL date function

dmxmikey
Creator
Creator
Author

as below?

where [act-date]<= date(today(), 'DDMMYYYY');

lcontezini
Partner - Creator
Partner - Creator

Yes, but first you need to check the format for [act-date]. It can be anything like 'DDMMYYYY', or 'YYYYMMDD'... Follow the steps:

1. Load this:

    Conprice:

    SQL SELECT "act-date",

    FROM price;

2. Take a look at [act-date] format.


    It can be anything like DDMMYYYY, YYYYMMDD, YYYY.MM.DD ...

3. Insert the format in the date clause, replacing the 'YYYYMMDD' bellow:

    Where [act-date]<= date(today(), 'YYYYMMDD');

dmxmikey
Creator
Creator
Author

here is my full script and still error.

Conprice:

SQL SELECT "act-date",

    "c-type",

    "claim-back",

    "con-group",

    "con-type",

    cost,

    "cost-rbon",

    "cost-uplift",

    "cust-code",

    "deact-date",

    depot,

    discount,

    "input-date",

    "last-sold",

    "last-update",

    "list-price",

    lwsv,

    "net-cost",

    "o-ordqty",

    operator,

    "p-code",

    qty,

    "qty-in",

    reported,

    "sell-price",

    "tran-stat-e",

    "tran-stat-s",

    "upd-date",

    weight,

    wsv

FROM PUB.conprice

Where [act-date]<= date(today(), 'DDMMYYYY');

dmxmikey
Creator
Creator
Author

The date is DDMMYYYY

lcontezini
Partner - Creator
Partner - Creator

LET vMax_Date = '"'&date(today(),'DDMMYYYY')&'"';

Conprice:

SQL SELECT "act-date",

    "c-type",

    "claim-back",

    "con-group",

    "con-type",

    cost,

    "cost-rbon",

    "cost-uplift",

    "cust-code",

    "deact-date",

    depot,

    discount,

    "input-date",

    "last-sold",

    "last-update",

    "list-price",

    lwsv,

    "net-cost",

    "o-ordqty",

    operator,

    "p-code",

    qty,

    "qty-in",

    reported,

    "sell-price",

    "tran-stat-e",

    "tran-stat-s",

    "upd-date",

    weight,

    wsv

FROM PUB.conprice

Where [act-date] <= $(vMax_Date);