2 Replies Latest reply: Dec 11, 2014 5:45 PM by Rayna Curtis RSS

    Weekday() in a SQL Statement

    Rayna Curtis

      I have written this as part of a SQL statement after a preceding load:

       

      SQL SELECT *

      FROM table1 RS INNER JOIN table2 PS

      ON RS.BUILDING_CODE=PS.BUILDING_CODE where date>=from_date and date<=to_date and

      ((WeekDay(date)=0 and "day_of_week_1_flag" = 'y') or (WeekDay(date)=1 and "day_of_week_2_flag" = 'y'))

       

      I am getting an error that says WeekDay not a recognized built in function.  It works in a Load statement, and as a sanity check I checked SQL online; it's a recognized SQL command, as well.

       

      Am I doing something wrong?  Any insight is appreciated!

        • Re: Weekday() in a SQL Statement
          Massimo Grossi

          WeekDay is a Qlik function, if you want to use weekday use in Qlik section of the load

           

          load

              weekday(date),

              ......

          where

              (weekday(date) = ... and ...)  or (...)

              ;

          sql select *

          FROM table1 RS INNER JOIN table2 PS

          ON RS.BUILDING_CODE=PS.BUILDING_CODE where date>=from_date and date<=to_date

               ;

           

           

           

          or if you have sql server as db, use datepart in the sql section of the statement

           

          load *;

          sql select *

          FROM table1 RS INNER JOIN table2 PS

          ON RS.BUILDING_CODE=PS.BUILDING_CODE where date>=from_date and date<=to_date

          and DATEPART ( dw , date ) = .......

              ;