Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Decode- Please Help
lakkundi_at_msn.com wrote in message <71okhv$g0m$1_at_nnrp1.dejanews.com>...
>Need to write a select statement that takes a date (eg. 15-DEC-97) and adds
>18 months to it. It must then print out the year-end (DEC 31) of that
>addition. For example, 18 months from Dec. 15 1997 is June 15, 1999, but
the
>year-end result that would be displayed is Dec. 31, 1999.
How about:
SELECT
TO_DATE( '31-Dec-' ||
TO_CHAR( ADD_MONTHS(sysdate,18), 'YYYY' ) , 'DD-MON-YYYY')
Don't understand why you want to use a DECODE. The ADD_MONTHS function returns any date and it is -very- difficult to decode a value that may be in any range. The logical way (IMO) is to add 18 months, extract the year, add 31st Dec to it and convert it back into a date. And it's Y2K compliant too! ;-)
regards,
Billy
Received on Wed Nov 04 1998 - 02:48:40 CST