| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: Find First of Month
Jeroen van den Broek wrote:
> DA Morgan wrote: >> Jeroen van den Broek wrote:
>>>> FireGeek wrote: >>>>> Looking for an SQL statement to return the first of the month 90 days >>>>> following a given date. So, if my date is 04/15/2006 I would like >>>>> 08/01/2006 returned. >>>>> >>>>> Help anyone? >>>>> >>>>> THANKS!!! >>>>> >>>>> FireGeek >>>> SELECT LAST_DAY(ADD_MONTHS(SYSDATE, 2))+1 >>>> FROM dual; >>>>
>>>
>>>
>> SELECT LAST_DAY(ADD_MONTHS(TO_DATE('31-DEC-2006'), 2))+1 FROM dual;
>> SELECT LAST_DAY(ADD_MONTHS(TO_DATE('31-DEC-2007'), 2))+1 FROM dual;
>> SELECT LAST_DAY(ADD_MONTHS(TO_DATE('31-DEC-2008'), 2))+1 FROM dual;
>> SELECT LAST_DAY(ADD_MONTHS(TO_DATE('31-DEC-2009'), 2))+1 FROM dual;
>>
>> Where's the problem?
>
> The OP used the expression "90 days following a given date".
> Nowhere in your solution this is accounted for.
> Just because he additionally asked for the 1th of the resulting month
> (or the next? see Maxim's reply), your solution will work most of the
> times, but like I said: not when starting at January 31th in a non-leap
> year, for the reason mentioned in my previous post.
> I can't make it any more clear than this.
Isn't this what the OP wrote?
"Looking for an SQL statement to return the first of the month 90 days following a given date. So, if my date is 04/15/2006 I would like 08/01/2006 returned."
That is not 90 days.
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.orgReceived on Fri Jul 14 2006 - 11:10:10 CDT
![]() |
![]() |