Home » RDBMS Server » Server Administration » date calculation routine
date calculation routine [message #371404] Fri, 13 October 2000 08:18
FELIX L. BOWMAN
Messages: 2
Registered: October 2000
Junior Member
" Hi, my name is Felix Bowman. I am `NEW` to oracle and I`m looking for a routine (or the possible correction of this sql script/ ) to calculate the difference between two date fields to obtain the exact day(s), month(s),yr(s) as separate fields and be able to execute any further calculations based on these values .

I designed a script on my own using forms 2.1 and oracle 7.3 but, sometimes the resulting fields aren`t exact , the reason ? . Attached to this message is the script itself as a way to illustrate you of what I am talking about .

THXS IN ADVANCE,
Felix Bowman

script :

B1.F1 = `18-NOV-63`;
B1.F2 = `05-SEP-00`;

select (:B1.F2 - Add_months(:B1.F1,floor(months_between(:B1.F2, :B1.F1)))) + 1 days,
FLOOR(FLOOR(MONTHS_BETWEEN(:B1.F2, :B1.F1))/12) years,
FLOOR(MONTHS_BETWEEN(:B1.F2, :B1.F1)) - FLOOR(FLOOR(MONTHS_BETWEEN(:B1.F2, :B1.F1))/12)*12 months
into :B1.Days, :B1.years, :B1.Months
from dual;
Previous Topic: query
Next Topic: date fields calculation
Goto Forum:
  


Current Time: Tue Apr 23 10:53:14 CDT 2024