|
-
Is their any easy( faster) way to find the number of business days between the 2 dates in PL/SQl block- procedure I am using Oracle 8.0.6 ?
I ususally do:
/*if startdate is sat or sun get the coming Mon as the start date*/
If to_char(dtTempStartdate1,'fmDay') ='Saturday'
or to_char(dtTempStartdate1,'fmDay') ='Sunday' then
Select Next_Day(dtTempStartdate1, 'Monday') into dtTempStartdate1 from dual;
end if;
/*If end date is Sat or Sun subtract 1 till you get to Fri*/
If to_char(dtTempEnddate1,'fmDay') ='Saturday'
or to_char(dtTempEnddate1,'fmDay') ='Sunday' then
Select Next_Day(dtTempEnddate1, 'Friday')-7 into dtTempEnddate1 from dual;
end if;
inDateCounter1:= dtTempEnddate1 - dtTempStartdate1 +1
- (Next_Day(dtTempEnddate1, 'Sunday')
- Next_Day(dtTempStartdate1, 'Sunday') )/7
- (Next_Day(dtTempEnddate1, 'Saturday')
- Next_Day(dtTempStartdate1, 'Saturday') )/7;
----------------------------------------
OR
-----------------------------------
While To_Number(TO_Char(dtTempStartdate2,'D')) =1
or To_Number(TO_Char(dtTempStartdate2,'D')) =7
Loop
dtTempStartdate2 :=dtTempStartdate2 +1;
End loop;
/*If end date is Sat or Sun subtract 1 till you get to Fri*/
While To_Number(TO_Char(dtTempEnddate2,'D')) =1
or To_Number(TO_Char(dtTempEnddate2,'D')) =7
Loop
dtTempEnddate2 := dtTempEnddate2-1;
End loop;
inDateCounter1:= dtTempEnddate1 - dtTempStartdate1 +1
- (Next_Day(dtTempEnddate1, 'Sunday') ...same as above....
Thanks
Sonali
Sonali
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|