Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Math equation needed to solve SQL problem
Hi.
You can use PL/SQL function to check it.
SELECT * FROM <your_table>
WHERE check_range ( table_date, :from_date, :to_date ) =1;
CREATE FUNCTION check_range ( dt IN DATE, fd IN DATE td IN DATE )
RETURN NUMBER IS
ttt DATE := NULL;
i NUMBER;
BEGIN
i := 0;
ttt := dt;
WHILE ttt < fd LOOP
ttt := ADD_MONTH ( ttt, 36 );
END LOOP;
IF ttt <= td THEN
i := 1;
END IF;
RETURN i;
END;
HTH. Michael.
In article <7vsd2b$vrn$1_at_nnrp1.deja.com>,
mrs_gleeson_at_my-deja.com wrote:
> Hi,
> I have a user entered date range (from, to).
> Lets say (08/01/1999- 08/31/1999)
> In the table I have record w/ unkown differnet dates. I need to pick
> the dates from the table that if I keep adding 3 years to them, they
> end up in the above date range.
>
> Example:
> the table_date (08/10/1993) if I keep adding 3 years to it, it will
end
> in the range
> (08/10/1993 + 3 yrs = 08/10/1996). Add another 3 yrs
> (08/10/1996 + 3 yrs = 08/10/1996). Add another 3 yrs = (08/10/1996 + 3
> yrs = 08/10/1999) which is in the range (08/01/1999- 08/31/1999).
>
> 2ND Example:
> the table_date (02/01/1994 + 3 yrs = 02/01/1997). Add another 3 yrs
> (02/01/1997 + 3 yrs = 02/01/2000) which is not in the range
> (08/01/1999- 08/31/1999).
>
> Please help! I need a math wizard to give me ONE select statement that
> contains a mathematical equation. Maybe there is a way in Oracle's
> function that can tell me if the table_date is between the date range
> or not????
> Thanks in advance.
> --MS.Gleeson
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Fri Nov 05 1999 - 08:37:42 CST
![]() |
![]() |