How to Calculate workdays in sql between assigned date and current date. Should exclude weekends.

I am using bigquery so the acceptable syntax is

datediff( CURRENT_DATE(),(timestamp(h.ARRIVAL_TIME_PAC_TZ))) as Aging_from_Arrival

calculates diffference between current and arrival date but it adds weekends too. Is there way to calculate only weekdays excluding weekends and holidays if possible.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DavidSenior Oracle Database AdministratorCommented:
DATEDIFF("weekday",[Calculation1],[Calculation2])-2*(DATEPART('week', [Calculation2]) -DATEPART('week', [Calculation1]))

Calculation 1, 2 are the dates
In oracle, I'd create a function to do the math

create or replace FUNCTION weekdays_between(p_start IN DATE, p_end IN DATE)
    v_start          DATE := TRUNC(LEAST(p_start, p_end));
    v_end            DATE := TRUNC(GREATEST(p_start, p_end));

    v_start_sunday   DATE := NEXT_DAY(v_start - 7, 'Sun');
    v_end_sunday     DATE := NEXT_DAY(v_end - 7, 'Sun');
    RETURN   v_end
           - v_start
           + 1 -- all days
           - (v_end_sunday - v_start_sunday) / 7 * 2 -- substract weekends
           - CASE WHEN TO_CHAR(v_start, 'Dy') = 'Sun' THEN 1 ELSE 0 END -- subtract first day if it is Sunday
           - CASE WHEN TO_CHAR(v_end, 'Dy') = 'Sat' THEN 1 ELSE 0 END -- substract last day if it is Saturday

I use next_day instead of trunc to make it easier to transition between NLS settings, just change Sat and Sun to whatever the abbreviation is for the language needed.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.