Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Today() into sql select

Dear all,

is it possible to insert today() function into an sql select. For example:

sql select field1, field2, year from table1 where  year < year(today());

I always get an error

Thanks for your help

Gr.

6 Replies
Highlighted
Not applicable

Re: Today() into sql select

try using GETDATE()

Highlighted
Specialist
Specialist

Re: Today() into sql select

Try year(getdate()) instead.

Highlighted
Not applicable

Re: Today() into sql select

Thanks very much. Is it right just for SQL SERVER or is it proper for ORACLE too ?

Gr.

Highlighted
Specialist
Specialist

Re: Today() into sql select

i'm using microsoft sql server.  not sure if it is the correct syntax for oracle.

Highlighted
Not applicable

Re: Today() into sql select

The GetDate() function is definitely the right answer in this case as suggested above.

However in some cases it may be needed to pass values from qlikview script to an sql statement.

Here's an example (something I've already used):

let vField1 = Peek('SystemField1',0,'RelatedTableFields');
let vField2 = Peek('SystemField2',0,'RelatedTableFields');

PropertyValues:
LOAD $(vField1), $(vField2);
SQL SELECT DISTINCT $(vField1), $(vField2) FROM $(vTableName);

Hope this will prove useful in future situations

Highlighted
Not applicable

Re: Today() into sql select

Hi, for Oracle, try this:

sql select field1, field2, year from table1 where  year < to_char(sysdate,'YYYY');

I hope that helps you.

Regards.

Zak