sp_QuickieStore - Bug in determining workdays
ehaar opened this issue · 0 comments
ehaar commented
Version of the script
@version = '4.5',
@version_date = '20240401';
What is the current behavior?
Somewhere around line 2450 a WHERE-clause is built to only include results for working-days (Mondays to Fridays).
If @df = 7 (first day of week is Sunday) the WEEKDAY-range must be between 2 and 6, which is correct.
However, if @df = 1 (first day of week is Monday) the WEEKDAY-range should be between 1 and 5, but sp_QuickieStore takes the range between 1 and 6. This way, the queries from Saturday would also be included, which is not right:
IF @df = 1
BEGIN
SELECT
@where_clause += N'AND DATEPART(WEEKDAY, qsrs.last_execution_time) BETWEEN 1 AND 6' + @nc10; <----- 6 should be 5
END;/*df 1*/
IF @df = 7
BEGIN
SELECT
@where_clause += N'AND DATEPART(WEEKDAY, qsrs.last_execution_time) BETWEEN 2 AND 6' + @nc10;
END;/*df 7*/