Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
haymarketpaul
Creator III
Creator III

Allowing the user to specify the date for SQL statement WHERE clause

Hi All

I have the following SQL statement in my script which works fine with a hard coded date, but, is there a way to allow the user to provide the date for the WHERE clause?  Can i use a mapping table within the SQL so perhaps the user could update a mapping spreadsheet when they need to?

Any ideas welcome...

ODBC CONNECT TO QlikView (XUserId is TaDfPUJMJbXIWSZOfScKWQRMFTcII, XPassword is LSTEecYNJCaMDTJKFJWOFLC);

HBI_temp:

SELECT

    userEmail

    ,usertitle

    ,userfirstname

    ,userlastname

    ,userid

    ,dateadded

FROM

    tbl_Users

WHERE

    dateadded > '2011-10-02'            //<<<<<<<<<<< date i would like to make more dynamic <<<<<<<<<<<<<<<

;

HBI_Data:

LOAD

    userEmail           as Email

    ,usertitle             as Title

    ,userfirstname     as Firstname

    ,userlastname     as Lastname

    ,userid                as userid  

    ,dateadded          as From_Date

Resident

    HBI_temp;

DROP Table

    HBI_temp;

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Just adding a note: there is also a system function to query the user to input a value during script execution:

Input( str cue [, str caption] )

This function can be used in the script only and opens an input box that prompts the user for a value during the script execution. The parameters cue and caption are used as message and caption texts, respectively. The function returns the entered value.

The input box function returns NULL if the dialog is cancelled, closed or cannot be shown.

Example:

Load
Input('Enter value', 'Input box') as v,
Recno () as r
autogenerate 3;

Regards,

Stefan

View solution in original post

5 Replies
richard_chilvers
Specialist
Specialist

Hi Paul

QV is very happy to extract data from Excel spreadsheets (you can use a wizard when writing the script). So this would be a good option. Create a spreasheet with a (single) date in it which your user can update. You may need a little validation in the script to make sure your user has asked for a 'sensible' date.

Regards

Not applicable

Hi. I do not understand what the problem is? Do like this/

haymarketpaul
Creator III
Creator III
Author

Very useful thank you - perfect for what i need to do

swuehl
MVP
MVP

Just adding a note: there is also a system function to query the user to input a value during script execution:

Input( str cue [, str caption] )

This function can be used in the script only and opens an input box that prompts the user for a value during the script execution. The parameters cue and caption are used as message and caption texts, respectively. The function returns the entered value.

The input box function returns NULL if the dialog is cancelled, closed or cannot be shown.

Example:

Load
Input('Enter value', 'Input box') as v,
Recno () as r
autogenerate 3;

Regards,

Stefan

haymarketpaul
Creator III
Creator III
Author

Fantastic - that's exactly what i need - Thankyou