Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can I transfer a QlikView variable to a SQL statement?

Hello

My document (qvw file) has a connection with a MS-SQL database.

In my script I use SQL statements like

Customer:
SQL
Select * from Customer;


Suppose I've a variable StartDate

SET StartDate=MakeDate(2012,01,01);

Is there a way to use the variable StartDate in a SQL statement?

Like

Customer:
SQL
Select * from Customer where Customer.Date >= StartDate;

I understand that in this example I better switch to QlikView syntax but I've fairly complex SQL statements that are hard to translate.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try this:

Customer:

SQL

Select * from Customer where Customer.Date >= '$(StartDate)';


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try this:

Customer:

SQL

Select * from Customer where Customer.Date >= '$(StartDate)';


talk is cheap, supply exceeds demand
nstefaniuk
Creator III
Creator III

Hi, it's an issue of format.

do something like that:

vDateString=Year( StartDate )&num(Month( StartDate ))&Day( StartDate );

Customer:

SQL

Select * from Customer where Customer.Date >=

CONVERT(datetime, '$(vDateString'), 112)

Not applicable
Author

Thank you

Not applicable
Author

Thank you