Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
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? 

1 Solution

Accepted Solutions
Jason_Michaelides
Luminary Alumni
Luminary Alumni

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

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

(been a long day..)

View solution in original post

4 Replies
Jason_Michaelides
Luminary Alumni
Luminary Alumni

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_Michaelides
Luminary Alumni
Luminary Alumni

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

Jason_Michaelides
Luminary Alumni
Luminary Alumni

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

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

(been a long day..)

Not applicable
Author

This worked. Thank you. Have a good one.