| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> strange function result
I have created the following function:
create or replace function AGE(a_bdate employee.bdate%type)
return INT IS
age INT;
Begin
select trunc(MONTHS_BETWEEN(SYSDATE, BDATE)/12) into age
from employee
where bdate = a_bdate;
RETURN age;
END AGE;
here is some sample data I get when I use it:
BDATE AGE
--------- ---------- 09-JAN-55 42 15-SEP-52 44 19-JUL-58 38 20-JUN-31 -34 08-DEC-45 -48 31-JUL-62 34 29-MAR-59 37 10-NOV-27 -30 10-OCT-65 31 19-DEC-70 26 28-JAN-03 -5
The problem calculates properly for the more recent birthdates, but later birthdates return a negative value. I explored the MONTHS_BETWEEN function and it returns INT type which is at least 2 bytes so I shouldn't be exceeding the range because i'm not close to 32,000. I know it can't be 1 byte because ex. 2 with age of 44 equals a MONTHS_BETWEEN of 528, which would be out of a 1 byte range and it works fine for it.
If anyone has any ideas as to what my problem might be please drop me a line. Any help is appreciated.
Thanks in advance,
Frankie Medlock
medlocrf_at_dunx1.ocs.drexel.edu
Received on Sun Feb 09 1997 - 00:00:00 CST
![]() |
![]() |