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: 
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
Not applicable
Author

try using GETDATE()

mphekin12
Specialist
Specialist

Try year(getdate()) instead.

Not applicable
Author

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

Gr.

mphekin12
Specialist
Specialist

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

Not applicable
Author

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

Not applicable
Author

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