| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: this cannot be then best way
What if you have some holiday in between?
Ed Prochak wrote:
> g wrote:
> > I have a date mydate and i want to subtract X working days off
> >
> > i was thinking of something like
> >
> > loop while x > 0
> > if to_char(mydate,'d') < 6 then
> > x = x -1
> > endif
> > mydate :mydate - 1
> > endloop
> >
> > any ideas
>
> If X tends to be large (>2weeks),
> then save a few passes thru the loop by
>
> --- computing the whole weeks
> whole_weeks := ( 7* (X/5) ) --- must use integer arithmetic
> mydate := mydate - whole_weeks
> x := mod(x,5)
> --- then put your loop here:
>
>
> HTH,
> ed
Received on Fri Jul 14 2006 - 13:47:42 CDT
![]() |
![]() |