🔹 Join the OracleApps88 Telegram Group - Stay up to date with the latest on Oracle EBS R12 and Oracle Cloud/Fusion Applications. 📌 Telegram Group : https://t.me/OracleApps88

💡 Facing issues copying code/scripts or viewing posts? We're here to help!
📬 Contact on Telegram : https://t.me/apps88
📱 Telegram/WhatsApp: +91 905 957 4321
📧 Email Support: OracleApp88@Yahoo.com

Friday, August 5, 2011

Calculating Weekdays between two dates

CREATE OR REPLACE FUNCTION totworkdays (fromdate DATE, todate DATE)
RETURN NUMBER
IS
totalsundays NUMBER;
totalsaturdays NUMBER;
BEGIN
totalsundays :=
NEXT_DAY (todate - 7, 'sunday') - NEXT_DAY (fromdate - 1, 'sunday');
totalsaturdays :=
NEXT_DAY (todate - 7, 'saturday') - NEXT_DAY (fromdate - 1, 'saturday');

RETURN (todate - fromdate - (totalsundays + totalsaturdays) / 7 - 1);
END totworkdays;

CALL this function as follows:


declare
lv_tot_work_days number;
BEGIN
lv_tot_work_days := totworkdays ('01-jan-2009', '31-jan-2009');
DBMS_OUTPUT.put_line ('Total Work Days: ' || lv_tot_work_days);
END;

No comments:

Post a Comment

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.
Best Blogger TipsGet Flower Effect