2 Replies Latest reply: May 19, 2017 10:39 AM by EZEQUIEL CONTE RSS

    Query field date in sql vs. Qv

    EZEQUIEL CONTE

      Good! How are you? In qv I have to load a table from a database, and filter by a specific date. The problem is that I do not understand how qv correctly interprets a date filter when it comes to a database.

      Attached image with code.

      Ima.jpgOn the web I did not find the solution. It throws me conversion error when I run it.


      Thank you! regards

        • Re: Query field date in sql vs. Qv
          Marcus Sommer

          The correct syntax depends on how the field is stored in the database and how cast() could transform it and the variable-values whereby the easiest approach is to keep it simple and to try to use the same formats. Quite often a date is stored as a number like 42874 for today - then you could use: let var = num(date#('03222015', 'MMDDYYYY')); to set the variable and you would be able to make a very simple where-clause, like: where FIELD_DATE >= $(var).

           

          Another way to simplify such where-conditions could be to apply them on a preceeding load, like:

           

          load * where FIELD_DATE >= $(var);

          select * from ...

           

          on which you could use qlikview-functions to determine your conditions. Of course this is only practically if the sql-load respectively their run-time is relative small because the whole sql-table will be queried on this way.

           

          - Marcus