Here is the code I currently have that gives me the last 12 days
SELECT *
FROM table
WHERE analysis_date >= current_date - interval '12' day;
analysis_date is the date column in the table. I understand why this isn't working because it's not accounting for business days. How can I rewrite this so that I get an interval of the last 12 business days?
I tried search online and found
extract(dow from (date))
But I couldn't find an example where I need a weekday interval. Any help would be appreciated.
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
CREATE INDEX table_idx_analysis_date ON "table" ("analysis_date");
SELECT
*
FROM
table
WHERE
table.analysis_date >= current_date - INTERVAL '12' day