Discussion Board for collaboration related to QlikView App Development.
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;
Try this:
SQL SELECT "act-date"
FROM price
where [act-date] <= CURRENT_TIMESTAMP
;
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());
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.
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
as below?
where [act-date]<= date(today(), 'DDMMYYYY');
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');
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');
The date is DDMMYYYY
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);