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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variable Date

Hello!  I have a load script that works but I use a hard-coded date (highlighted in red below). But I want to use an arbitrary date value, vStartDate, instead of the hard-coded date. How can I use the value of vStartDate?

LET vStartDate = makedate(Year(Today()),01,01);

YTDtotals:

LOAD

item,

ytd_units,

ytd_cost,

ytd_price;

SQL SELECT t3.item,

    sum(t1.units) as ytd_units,

    sum(t1.total_cost) as ytd_cost,

    sum(t1.total_price) as ytd_price

FROM transitem t1, trans t2, product t3

       where t1.trn_uid = t2.trn_uid

       and t1.product_uid = t3.product_uid

       and t2.trn_date > '2011-01-01'

       group by t3.item;

1 Solution

Accepted Solutions
MayilVahanan

HI

Use like this

       and t2.trn_date  > '$(vStartDate )'


Edit:

LET vStartDate = makedate(Year(Today()),01,01); gives 01/01/2012

so use

LET vStartDate = makedate(Year(Today())-1,01,01); gives 1/1/2011

For format,

Date(makedate(Year(Today())-1,01,01),'YYYY-MM-DD')

Hope that helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

2 Replies
MayilVahanan

HI

Use like this

       and t2.trn_date  > '$(vStartDate )'


Edit:

LET vStartDate = makedate(Year(Today()),01,01); gives 01/01/2012

so use

LET vStartDate = makedate(Year(Today())-1,01,01); gives 1/1/2011

For format,

Date(makedate(Year(Today())-1,01,01),'YYYY-MM-DD')

Hope that helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

Thank you!