Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
Not applicable

use date as a variable ?

i have generate two variable of date like that .. i think is a variable


LOAD
date(date#(20050101,'YYYYMMDD')+recno(),'DD/MM/YYYY') as "Date_start"
AUTOGENERATE today() - MakeDate(2005, 1, 1) + 1;

LOAD
date(date#(20050101,'YYYYMMDD')+recno(),'DD/MM/YYYY') as "Date_end"
AUTOGENERATE today() - MakeDate(2005, 1, 1) + 1;


and after i select them and load the script must execute a sql query like that :


and i.trndate
between convert(datetime,'$Date_start',103)
and convert(datetime,'$Date_end',103)


i receive an error :

SQL error: Syntax error converting datetime from character string.
Script line: .... and i.trndate between convert(datetime,'$Date_start',103) and convert(datetime,'$Date_end',103)

any tips ?

Tags (2)
3 Replies
sparur
Valued Contributor II

use date as a variable ?

Date_start and Date_end in your script aren't variables.

You create a 2 fields 🙂

for create a variable try that after your load script;

LET vStartDate = peek('Date_start', 0) ;

LET vEndDate = peek('Date_end', 0) ;

and than use this variable in your later script. But I'm not sure about sql function convert().

Not applicable

use date as a variable ?

and in the sql query who i can use them ?

with $ or in '' ??

MVP & Luminary
MVP & Luminary

use date as a variable ?

convert(datetime,'$(vStartDate)',103)

The expression reference syntax is:

$(varname)

Don't forget the parens.

-Rob