Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

Creating a string variable for today's date

I would like to query a postgres database to load a table. I need to make the query dinamic. For Example, a simple query would look like this:

SELECT *

FROM  table1

WHERE date(reportdate) = '2012-07-16'

I want to feed the date  '2012-07-16' in WHERE statement above using today() function in the qlikview. So I need to convert the result of the Today() function in a string which looks like  '2012-07-16'.  so that i can write above query as:

SELECT *

FROM  table1

WHERE date(reportdate) = $(vdate)

in this query $(vdate) should produce '2012-07-16'. How can i do that? 

Tags (2)
1 Solution

Accepted Solutions
jason_michaelid
Honored Contributor II

Re: Creating a string variable for today's date

PPS - I forgot the closing Chr(39)...

Let vDate = Chr(39) & Date(Today(),'YYYY-MM-DD') & Chr(39);

(been a long day..)

4 Replies
jason_michaelid
Honored Contributor II

Re: Creating a string variable for today's date

Above the load portion of the scrip put:

Let vDate = Chr(39) & Date(Today(),'YYYY-MM-DD');

Then use the SELECT statement exactly as you write above.

Hope this helps,

Jason

jason_michaelid
Honored Contributor II

Re: Creating a string variable for today's date

PS - the 'amp;' is my iPhone playing silly buggers....

jason_michaelid
Honored Contributor II

Re: Creating a string variable for today's date

PPS - I forgot the closing Chr(39)...

Let vDate = Chr(39) & Date(Today(),'YYYY-MM-DD') & Chr(39);

(been a long day..)

Not applicable

Re: Creating a string variable for today's date

This worked. Thank you. Have a good one.

Community Browser