4 Replies Latest reply: Feb 2, 2015 6:20 PM by Peter Cammaert RSS

    Variable in script

    ria Desai

      I have a standard version date that I want to use in all the tabs in the load statements.

      I have created below table in the beginning in main and stored it in variable vVersionDate.








      select distinct END_DT as VERSION_DATE from TIME_V where DAY_DATE = TRUNC(SYSDATE);

      Let vVersionDate = peek('VERSION_DATE',0,VERSIONDATE);



      But I am not able to make it work in all the tabs

      I tried using below in the load statement in one of the tables. It doesnt work.

      date($(vVersionDate)) as VERSION_DT,


      I get below error


      can anyone help me here.

        • Re: Variable in script
          Nagaian Krishnamoorthy

          Try the following: (VERSIONDATE in quotes)

          Let vVersionDate = peek('VERSION_DATE',0,'VERSIONDATE');

          • Re: Variable in script
            Oleg Troyansky

            It is most likely a formatting problem. Your date is coming back from the database as a fully formatted timestamp. You can try a few options and see which one works:


            1. Try to simply convert the incoming date into a number:


            Let vVersionDate = num(peek('VERSION_DATE',0,VERSIONDATE) );

            2. If that doesn't work, then try to convert the full timestamp string into a date field, and then convert it into a number:

            Let vVersionDate =




                           'M/D/YYYY hh:mm:ss TT'





            Oleg Troyansky

            Check out my book QlikView Your Business - now available to pre-order on Amazon!

            • Re: Variable in script
              Peter Cammaert

              The peek() seems to be working already, maybe only once in a while.


              However, if vVersionDate contains 2/7/2015 12:00:00 AM, then simply using the variable value as a parameter to the date() function will produce an illegal script expression, like date(2/7/2015 12:00:00 AM) as VERSION_DT. QlikView cannot correctly interprete the parameter.


              Again, use quotes to turn the value into a string which QlikView will be able to handle. Like




              date('$(vVersionDate)') AS VERSION_DT,