Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Decode- Please Help
On Wed, 04 Nov 1998 04:18:07 GMT, lakkundi_at_msn.com wrote:
>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.
>
>
>I can write this with date functions but I need to make it more dynamic with a
>decode.
>How do I do this. I tried and tried, please help..
>
>Thanks so much for your help
I can't see any conditional logic required in your description of a problem. Can you explain in more detail what would the DECODE be used for?
And what can be more general sollution for your problem as using simple date functions? Eg
SELECT ADD_MONTHS(TRUNC(ADD_MONTHS(sysdate,18),'YEAR'),12)-1 FROM dual;
HTH,
Jurij Modic <jmodic_at_src.si>
Certified Oracle7 DBA (OCP)