Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Birthday Query

Re: Birthday Query

From: Brian Tkatch <SPAMBLOCK.Maxwell_Smart_at_ThePentagon.com.SPAMBLOCK>
Date: Wed, 24 Oct 2001 01:41:23 GMT
Message-ID: <3bd61a44.1072713750@news.alt.net>


On Tue, 23 Oct 2001 22:56:47 GMT, "Scott Mattes" <ScottMattes_at_yahoo.com> wrote:

>Brian,
> Yes, it does die on 1/1 (I sat down and did a test PL/SQL this time).
>
> Does it have to be a SQL solution? Could you use PL/SQL? At least that
>would be easier to read once you come up with a solution.
>

Oh, I do have a solution, and I did post it. Here it is the fragment.

AND(ADD_MONTHS(Birthday, MONTHS_BETWEEN(TRUNC(SYSDATE,'YYYY'), TRUNC(Birthday, 'YYYY'))) BETWEEN (SYSDate - 15) AND (SYSDate + 15) OR ADD_MONTHS(Birthday, MONTHS_BETWEEN(TRUNC(SYSDATE,'YYYY'), TRUNC(Birthday, 'YYYY')) + 12) BETWEEN (SYSDate - 15) AND (SYSDate + 15))

Note the second check to capture when the year wraps. That is, when the birthday is 1/1 and we're running on 12/31.

I could use PL/SQL, but I don't see how it would be quicker. It's not like it could be DETERMINISTIC.

I did write a function, however, to use elsewhere. Here it is.

CREATE OR REPLACE Function Amount_Of_Days_This_Year (The_Date IN Date) RETURN NUMBER DETERMINISTIC IS
BEGIN

 RETURN Target - Today;

END Days_Until;
/

I wrote those a while back. I ought to change NUMBER to PLS_INTEGER.

Brian Received on Tue Oct 23 2001 - 20:41:23 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US