1 Reply Latest reply: May 14, 2012 6:09 PM by Tom Hoch RSS

    Variable Issue

      I want to load data belonging to the latest batch of data.

       

      I created a max date for data i receive form a database.

      MaxDate:

      Load Max(Date(Date#(MONTH_BATCH,'YYYY-MM'),'YYYY-MM')) as MaxDate

      resident Test ;

       

      Let vMaxDate = Date(Date#(peek('MaxDate', -1),'YYYY-MM'),'YYYY-MM')

       

       

      When I load the data form the qvd with all the data, I plan to use the vMaxDate variable in the where clause.

       

      The variable returns the right value ie., '2012-05' when i check it in a text box with the expression '=vMaxDate'

       

      But when I use =$(vMaxDate), the value it returns is 2007.

       

      What could be the issue here?

       

       

        • Variable Issue
          Tom Hoch

          Hi Bharath,

           

          Your date is being evaluated as string so when you expand the variable vMaxDate QV is interpreting it as 2012 - 5 which equals 2007.

           

          To have it evaluate to a date remove the date function like this:

           

          MaxDate:

          Load Max(Date#(MONTH_BATCH,'YYYY-MM'),'YYYY-MM') as MaxDate

          resident Test ;

           

          And to set it to the variable:

           

          Let vMaxDate = peek('MaxDate', 0);

           

          The variable will then be 41030 which is May 1, 2012.