Home » SQL & PL/SQL » SQL & PL/SQL » PL/SQL function (merged)
PL/SQL function (merged) [message #257105] Tue, 07 August 2007 10:33 Go to next message
Messages: 85
Registered: April 2006
Location: Delhi

How can find the 10th working date in a current month excluding saterday & sunday.

Re: PL/SQL function [message #257114 is a reply to message #257105] Tue, 07 August 2007 10:47 Go to previous messageGo to next message
Michel Cadot
Messages: 64953
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Please on the board or on AskTom for "working day".
icon1.gif  KR_Arvind==Function you looking for [message #257145 is a reply to message #257105] Tue, 07 August 2007 11:42 Go to previous message
Messages: 9
Registered: August 2007
Junior Member
create or replace function get_10th_date(p_date date default sysdate) return date is
v_mon varchar2(10);
v_year varchar2(4);
v_exit_flag number(1) := 0;
v_date date;
day_cnt number := 1;
tmp_day varchar2(20);
     v_mon := to_char(p_date,'MM');
     v_year := to_char(p_date,'YYYY');
     v_date := to_date(v_mon||'01'||v_year,'mmddyyyy');

          exit when day_cnt = 10;
          tmp_day := to_char(v_date,'DAY');
          if ltrim(rtrim(tmp_day)) in ('SATURDAY','SUNDAY') then
             v_date := v_date+1;
             v_date := v_date+1;
             day_cnt := day_cnt + 1;
          end if; 
    end loop;

        return v_date;

KR_ARVIND.. As your thread was closed...created this new one...
I find your issue interesting , had free time, and created few lines of code as above...Is this what you looking for?
Previous Topic: Error is missing keyword when am executing dynamic PL/SQL program
Next Topic: create a text file and write data (merged)
Goto Forum:

Current Time: Fri Jun 23 17:35:42 CDT 2017

Total time taken to generate the page: 0.14689 seconds