Re: Pesky Date Question
Date: Tue, 15 Jun 1999 14:03:30 -0400
Message-ID: <37669572.AB2262F2_at_ditw.com>
Try this:
lv_anniv_start := ADD_MONTHS(cyb_rec.seniority_date, (TO_CHAR(SYSDATE,'YYYY') - TO_CHAR(cyb_rec.seniority_date, 'YYYY'))*12);
This calculates the number of months for the number of years to advance and then uses the Oracle function "add_months" which will handle the leap year problem.
-- Alton
Ken Halsted wrote:
Question to Oracle Guru's,Received on Tue Jun 15 1999 - 20:03:30 CESTIs there a way to fix the following code so that it is more accurate.
txt := to_char(cyb_rec.seniority_date,'MMDD')||to_char(sysdate,'YYYY'); --
txt is a VARCHAR2
lv_anniv_start := to_date(txt,'MMDDYYYY'); -- lv_anniv_start is a DATEThose two lines are part of my code now and the problem is if the employee's
seniority_date is '02291996', I get an error because there is no 02291999.All I need is a way to convert a persons seniority_date (hire_date) to the
current year. For example, If I was hired on 02/29/1996, I want to convert
it to 02/28/1999 or 03/01/1999, whichever makes the most sense.Please help.
Thanks,
Ken.
--
_________________
Kenneth W. Halsted
Mountaire Corporation
ph: (501) 399-8812
url: http://www.mountaire.com
email: kenman_at_mail.snider.net