Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
raynac
Partner - Creator
Partner - Creator

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
maxgro
MVP
MVP

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

    ;

View solution in original post

2 Replies
maxgro
MVP
MVP

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
Partner - Creator
Partner - Creator
Author

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!