Monster dating service missing database vba
Perhaps I missed something in my hurry, but a function based on the next coding wordks for me: declare v_date date; v_bool boolean := FALSE; begin v_date := to_date('&datum','DDMMYYYY'); if v_date = last_day(v_date) then v_date := v_date - 1; v_bool := TRUE; end if; v_date := add_months(v_date, &aantal); if v_bool then if v_date = last_day(v_date) then null; else v_date := v_date 1; end if; end if; dbms_output.put_line(to_char(v_date, 'DDMMYYYY')); end; @Ron: Your function does solves the "bug" with the "design" of Add Months not making the Result Day of Month = Source Day of Month when Source Date = Last Day of Source Date's Month and Result Date's Month has more Days than Source Date's Month.However: a) It doesn't solve the Original Poster's Q, which is to make the Result Day of Month 1 Day less than the Source Date's Day of Month (even when not in end-of-month scenarios).Add_months is cool Thanks Tom Dear Tom, good day to you, hope you are fine and doing good, I am facing one small issue with add_months below is the scenario.below query returns 27/02/2008 which is fine select add_months(to_date('27/02/2005','dd/mm/yyyy'),36) from dual; but if i change the query to select add_months(to_date('28/02/2005','dd/mm/yyyy'),36) from dual it returns 29/02/2008, I want to know why 28/02/2008 is missed, basically I am working on a script which selects max date from a column of table and for each day of next 3 years inserts the records in the table if there's a leap year between the day is missed, how can this be rectified.I hope this example makes things a little clear for you.Kind Regards, Vijay November 17, 2005 - am UTC but it is putting in feb 29th. You have something on the last day of a MONTH, add months says "add a month to the last day of a month, you get the last day of the resulting month" select to_date('31-jan-2005') interval '1' month from dual; select to_date('31-jan-2005') interval '1' month from dual * ERROR at line 1: ORA-01839: date not valid for month specified [email protected] select to_date('31-jan-2005') interval '2' month from dual; TO_DATE(' --------- 31-MAR-05 I'm not fond of interval math too much - not with adding months anyway.
A 12-month Policy Effective 2/28/2003 (@ am) would Expire on 2/28/2004 (@ am), not the 2/29/2004 Add Months (2/28/2003, 12) would return. Of course, those are all in software produced by a little company in Washingtion. Don't want to be the wise guy, but if I simplify my test script it would look like this: begin if Sourcedate = last_day(Sourcedate) then Sourcedate := Sourcedate - 1; Sourcedate := add_months(Sourcedate, Num Months); Sourcedate := Sourcedate 1; else Sourcedate := add_months(Sourcedate, Num Months); end if; -- Sourcedate :- Sourcedate - 1 ( the original quest ) end This is clear and readable, is it not? Something that you (clearly) have taken care of in your solution.SQL select datum,add_months(trunc(datum,'MONTH'),12) 2 case 3 when to_char(datum,'DDMM')='2902' then null 4 else to_number(to_char(datum,'DD')-1) end datum_yar 5 from toto 6* order by 1 DATUM DATUM_YAR --------- --------- 25-FEB-00 25-FEB-01 26-FEB-00 26-FEB-01 27-FEB-00 27-FEB-01 28-FEB-00 28-FEB-01 29-FEB-00 01-MAR-00 01-MAR-01 02-MAR-00 02-MAR-01 03-MAR-00 03-MAR-01 04-MAR-00 04-MAR-01 05-MAR-00 05-MAR-01 06-MAR-00 06-MAR-01 ...DATUM DATUM_YAR --------- --------- 18-FEB-03 18-FEB-04 19-FEB-03 19-FEB-04 20-FEB-03 20-FEB-04 21-FEB-03 21-FEB-04 22-FEB-03 22-FEB-04 23-FEB-03 23-FEB-04 24-FEB-03 24-FEB-04 25-FEB-02 25-FEB-03 26-FEB-02 26-FEB-03 27-FEB-02 27-FEB-03 28-FEB-02 28-FEB-03 01-MAR-02 01-MAR-03 02-MAR-02 02-MAR-03 First, let me clear the confusion most people seem to have about Add_Months Function.To do that, you just need to subtract 1 from the result at the end of your Function (or one that calls your Function to do what the Poster needs). It uses 2 Local Var's, 3 If's, 1 Else and 5 Assign's.If you converted my Case Expression to a Function, it would just need 1 Local Var, 1 If, 1 Else and 3 Assign's.