Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

raynac
Contributor

Weekday() in a SQL Statement

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!

1 Solution

Accepted Solutions
MVP
MVP

Re: Weekday() in a SQL Statement

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 ) = .......

    ;

2 Replies
MVP
MVP

Re: Weekday() in a SQL Statement

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 ) = .......

    ;

raynac
Contributor

Re: Weekday() in a SQL Statement

Thank you so much!!  I got this via email and didn't even read the second half.  The first half of your response appears to have gotten the view to do precisely what I wanted it to do.

Thank you again!