Months between Dates

Hi All,
How do i get the number of months between 2 dates ?
I have the 2 dates stored as
Date EffctFrmDt = voRow.getEffectiveFromDate();
Date EffctToDt = voRow.getEffectiveToDate();
The values printed for EffctFrmDt & EffctToDt are 2008-06-11 & 2008-10-31
I'm trying to print the months
System.out.println("Date diff : " + EffctFrmDt.diffInMonths(EffctToDt));
I get the following Error stack
oracle.apps.fnd.framework.OAException: oracle.jbo.domain.GenericDomainException: JBO-25023: Error while performing operation:Date.diffInMonths on domain value:2008-06-11 of class:oracle.jbo.domain.Date.
at oracle.apps.fnd.framework.OAException.wrapperException(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
## Detail 0 ##
java.sql.SQLException: Unimplemented method called
at oracle.sql.LdxLibThin.ldxsbm(LdxLibThin.java:1402)
at oracle.sql.DATE.diffInMonths(DATE.java:918)
at oracle.jbo.domain.Date.diffInMonths(Date.java:507)
at agi.oracle.apps.cn.quota.webui.CustomSnltyCreatePgCO.processFormRequest(CustomSnltyCreatePgCO.java:281)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
java.sql.SQLException: Unimplemented method called
at oracle.sql.LdxLibThin.ldxsbm(LdxLibThin.java:1402)
at oracle.sql.DATE.diffInMonths(DATE.java:918)
at oracle.jbo.domain.Date.diffInMonths(Date.java:507)
at agi.oracle.apps.cn.quota.webui.CustomSnltyCreatePgCO.processFormRequest(CustomSnltyCreatePgCO.java:281)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
Am I doing anything wrong or is there some other approach to this ??
Thanks and Regards,
Dean

There can be two possible approcahes:
JAVA
Use calendar class, its pretty straight forward.
sql
SELECT MONTHS_BETWEEN('01-JAN-01','01-AUG-01') AS MONTHS_BETWEEN FROM Dual;
Please do a google before basic threads for core java.
--Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How to get LASTDAY for each and every month between given dates..

    Hi Friend,
    I have a doubt,How to get LASTDAY for each and every month between given dates..
    for ex:
    My Input will be look like this
    from date = 12-01-2011
    To date = 14-04-2011
    And i need an output like
    31-01-2011
    28-02-2011
    31-03-2011
    is there any way to achieve through sql query in oracle
    Advance thanks for all helping friends

    Here's a 8i solution :
    select add_months(
             trunc(
               to_date('12-01-2011','DD-MM-YYYY')
             ,'MM'
           , rownum ) - 1 as results
    from all_objects
    where rownum <= ( months_between( trunc(to_date('14-04-2011','DD-MM-YYYY'), 'MM'),
                                      trunc(to_date('12-01-2011','DD-MM-YYYY'), 'MM') ) );
    The above two query is worked in oracle 11GActually the first query I posted is not correct.
    It should work better with
    months_between(
       trunc(to_date(:dt_end,'DD-MM-YYYY'),'MM'),
       trunc(to_date(:dt_start,'DD-MM-YYYY'),'MM')
    )Edited by: odie_63 on 12 janv. 2011 13:53
    Edited by: odie_63 on 12 janv. 2011 14:11

  • Need Help on List of Months between Two Dates

    Hello everyone,
    I have a table which has startdate & enddate, and need a SELECT statement to list all months between these two dates for each given ID.
    I did some test, and could not figure out how to get the startdate & enddate from testing table (instead of hard code them) in the select statement.
    Could anybody please help on it (Oracle 11gR2),
    Thanks in advance!!!
    create table testing(
    id          number,
    start_date  date,
    end_date    date);
    insert into testing values(100, to_date('05-FEB-2011', 'DD-MON-YYYY'), to_date('28-MAY-2011', 'DD-MON-YYYY'));
    insert into testing values(200, to_date('20-JUN-2011', 'DD-MON-YYYY'), to_date('28-DEC-2011', 'DD-MON-YYYY'));
    commit;
    select * from testing;
            ID START_DAT END_DATE
           100 05-FEB-11 28-MAY-11
           200 20-JUN-11 28-DEC-11
    Elapsed: 00:00:00.01
    *for testing.id = 100:*
    select to_char(add_months(to_date('05-FEB-2011', 'DD-MON-YYYY'), l - 1), 'YYYY-Mon') Dates
    from (select level l
           from dual
        connect by level <= months_between(trunc(to_date('28-MAY-2011', 'DD-MON-YYYY'), 'MONTH'),
                                           trunc(to_date('05-FEB-2011', 'DD-MON-YYYY'), 'MONTH')) + 1);
    DATES
    2011-Feb
    2011-Mar
    2011-Apr
    2011-May
    Elapsed: 00:00:00.01
    *for testing.id = 200:*
    select to_char(add_months(to_date('20-JUN-2011', 'DD-MON-YYYY'), l - 1), 'YYYY-Mon') Dates
    from (select level l
           from dual
        connect by level <= months_between(trunc(to_date('28-DEC-2011', 'DD-MON-YYYY'), 'MONTH'),
                                           trunc(to_date('20-JUN-2011', 'DD-MON-YYYY'), 'MONTH')) + 1);
    DATES
    2011-Jun
    2011-Jul
    2011-Aug
    2011-Sep
    2011-Oct
    2011-Nov
    2011-Dec
    7 rows selected.

    SQL> select * from testing
      2  /
            ID START_DAT END_DATE
           100 05-FEB-11 28-MAY-11
           200 20-JUN-11 28-DEC-11
    SQL> select  id,
      2          to_char(add_months(start_date,column_value - 1),'YYYY-Mon') dates
      3    from  testing,
      4          table(
      5                cast(
      6                     multiset(
      7                              select  level
      8                                from  dual
      9                                connect by add_months(trunc(start_date,'MM'),level - 1) <= end_date
    10                             )
    11                     as sys.OdciNumberList
    12                    )
    13               )
    14    order by id,
    15             column_value
    16  /
            ID DATES
           100 2011-Feb
           100 2011-Mar
           100 2011-Apr
           100 2011-May
           200 2011-Jun
           200 2011-Jul
           200 2011-Aug
           200 2011-Sep
           200 2011-Oct
           200 2011-Nov
           200 2011-Dec
    11 rows selected.
    SQL> SY.

  • List Months between a date range

    Hi, I'm trying to list the months between a given date range in an ABAP report to generate a MIS report(ALV).. Say I have 2 date ranges, 01.01.2006 to 01.04.2006.. I want to list
    Jan 2006
    Feb 2006
    Mar 2006
    Apr 2006.. Any FM in SAP to get this OP..

    hi vivek,
    use this function module to get months beween two dates
    1. MONTHS_BETWEEN_TWO_DATES   or
    2. MONTHS_BETWEEN_TWO_DATES_NEW
    please reward the point if you are satisfied with answer
    thanks,
    john.

  • Generate all Months between start and end dates using Parameter

    Hi,
    I have a query in which i have two dates that is Start Date and End Date and now i have to populates all the Months between the date range:
    Start Date : APR-12
    End Date: JUL-12
    Now taking these two values i want the recors as displayed below
    APR-12
    MAY-12
    JUN-12
    JUL-12
    So how can write my SQL query to finish this task
    Thanks

    Sounds easy with single pair of Months:
    with data(st_dt, end_dt) as
      select to_date('JAN-2012', 'MON-YYYY'), to_date('SEP-2012', 'MON-YYYY') from dual
    select add_months(st_dt, level - 1  ) mons
      from data
    connect by level <= months_between(end_dt,st_dt) + 1;
    MONS   
    01-JAN-12
    01-FEB-12
    01-MAR-12
    01-APR-12
    01-MAY-12
    01-JUN-12
    01-JUL-12
    01-AUG-12
    01-SEP-12
    9 rows selected Please ensure to read {message:id=9360002} and post the question correctly with all the mentioned points in the thread. It facilitates the people to understand the problem clearly and provide a solution that is compatible with your Oracle Version.

  • Find year,month & day between dates

    Hi,
       I need to find a number of years, months & day between a given dates. For example If a employee joined on 31.01.2003 and left on 01.06.2006, I need to find in between how many years, months & days he has worked. Is there any function module available .

    DATA: EDAYS LIKE VTBBEWE-ATAGE,
    EMONTHS LIKE VTBBEWE-ATAGE,
    EYEARS LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
    TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
    Call Function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
      exporting
        i_date_from          = FROMDATE
        i_date_to            = TODATE
    *   I_FLG_SEPARATE       = ' '
      IMPORTING
        E_DAYS               = EDAYS
        E_MONTHS             = EMONTHS
        E_YEARS              = EYEARS.
    WRITE:/ 'Difference in Days   ', EDAYS.
    WRITE:/ 'Difference in Months ', EMONTHS.
    WRITE:/ 'Difference in Years  ', EYEARS.
    INITIALIZATION.
    FROMDATE = SY-DATUM - 60.
    Using teh abiove u can get difference but when u pass previous year u wont get the exact.
    There is no seperate FM for this, u have to use three FM.
    If possible using these three FM code u can create an FM.
    <b>For years and months between two days:</b>
    DATA:   EYEARS  LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE PREL-BEGDA,
                     TODATE   LIKE PREL-BEGDA DEFAULT SY-DATUM.
    CALL FUNCTION 'COMPUTE_YEARS_BETWEEN_DATES'
      EXPORTING
        first_date                        = fromdate
    *   MODIFY_INTERVAL                   = ' '
        second_date                       = todate
    IMPORTING
       YEARS_BETWEEN_DATES               =  EYEARS
    * EXCEPTIONS
    *   SEQUENCE_OF_DATES_NOT_VALID       = 1
    *   OTHERS                            = 2
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Write:/ eyears.
    DATA:       EMONTHS LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE SY-DATUM,
                TODATE   LIKE SY-DATUM
    DEFAULT SY-DATUM.
    CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
      EXPORTING
        i_datum_bis         = fromdate
        i_datum_von         = todate
    *   I_KZ_INCL_BIS       = ' '
    IMPORTING
       E_MONATE            = emonths
    write:/ emonths
    CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
    EXPORTING
    I_DATUM_BIS = x_faede-zfbdt
    I_DATUM_VON = p_fdat
    I_KZ_EXCL_VON = '0'
    I_KZ_INCL_BIS = '0'
    I_KZ_ULT_BIS = ' '
    I_KZ_ULT_VON = ' '
    I_STGMETH = '0'
    I_SZBMETH = '1'
    IMPORTING
    E_TAGE = dias_v.
    IF SY-SUBRC <> 0.
    ENDIF.
    x_faede-zfbdt -> 20050915
    p_fdat -> 20050811
    dias_v = 4
    try this and let me know.
    Message was edited by:
            Judith Jessie Selvi

  • Months between two date

    There two ways of finding months between two dates
    ROUND((Date1 – Date2) / 365.25 * 12,2) and
    ROUND(months_between(date1,date2),2) There is a slight difference between output from these two.
    I think the result from the second statement should be more accurate, confirm?
    Abhishek

    AbSHeik wrote:
    There two ways of finding months between two dates
    ROUND((Date1 – Date2) / 365.25 * 12,2) and
    ROUND(months_between(date1,date2),2) There is a slight difference between output from these two.
    I think the result from the second statement should be more accurate, confirm?
    AbhishekHi Abhishek,
    I also agree with this.
    Coz 365.25 = (365 + (1/4))
    This 0.25 actually the extra year of a Leap Year, distributed equally among 4 years. But, when the 1st formula is evaluated, the calculation might cause difference...
    So as far as Oracle is concerned, MONTHS_BETWEEN should be used.
    Please rectify me if i'm wrong.
    Ranit B.

  • How to Calculacte No of Months between 2 give dates at Report Leve

    Hi Experts,
      I had 2 Key Figures of DATs Format...
      I can i calculacte No of Months between 2 given dates at Bex Query Designer Level
    I am intrested in Calculacting exact months...not No of Days
    Please advise

    Try creating 2 replacement variables of number format to include only the month and then use a formula to get the difference between the var 1 and var 2.
    Hope this helps.
    Best Regards,
    Hima

  • Discrepancy between OD entered in Months and Dates

    Hi all,
    We are facing a problem while entering the OD in Months.
    Example :
    When we enter the duration as 8m (for 8 Months) the dates shown are :
    12-Feb-10 to 10-Aug-10. The dates which we want are 12-Feb-10 to 12-Oct-10.
    The calendar selected is a 7 day week calendar and hours setting are 8 hours / day
    Also the Time Units user preferences are set to 8 hours / day.
    For the moment, we adjust the dates by selecting them irrespective of the OD.
    Kindly advise suitably.
    With Warm Regards,
    Uhde India Planning

    first of all, you should consider conversion of input data and scheduling (F9) as two different things.
    P6 versions prior to v7 use the admin prefs for time units (default values are 8h/d, 40h/w, 172h/m, 2000h/y) to convert between input unit of time for durations and the user pref display unit of time for durations.
    if you so choose (but I would recommend against it), you can allow different users to use different conversion sets (checkbox under admin/ admin prefs) and define custom user conversion sets (under edit/ user prefs).
    also check viewing options (under user prefs) for time sub-units, decimal points for duration fields and date-time (not just date) for date fields.
    the value you input in a duration field (such as OD of let's say "2m") is converted into h based on the aplicable h/m setting (=> 2*172=344h), and then back into whatever the user has set as display unit for durations (let's assume days => 344/8=43d displayed in the OD field).
    when scheduling (F9), the activity planned (early) finish date (& time) is calculated as planned (early) start date (& time) + original duration working hour count
    regardless of what the OD field displays in days (!). the database level name of the OD field is just that "target_duration_hr_cnt"
    scheduling is done by taking into account applicable activity/resource calendar first (depending on activity type), and then h/d for different days, d/m for different months, etc (as defined for the calendar in use). in other words, considering daily working period, lunch breaks, weekends, holidays, custom calendar exceptions.
    there are numerous other settings for scheduling (check out scheduling options). levelling (Shift+F9) is basically scheduling that comes with its own set of options and takes things to the next level by considering resource avaliability, float, maximum overallocation, network, constraints or custom project & activity levelling priority, etc.
    long story short :)
    the expected PF = PS + OD - 1 holds for Planned Start of Jan 1 + Original Duration of 3d = Planned Finish of Jan 3 but not for OD of 3m.
    whenever possible, you should try to build your schedule using:
    - relatively short activities (order of days or even hours =>durations input in days or even hours). the fewer conversions needed when inputing, the better.
    - consistent h/d, d/w within a given month. the fewer calendar exceptions the better.
    - correlation between the admin duration conversion set (8,40,172,2000) and activity/resource calendars (8h/d, 5d/w used for activity scheduling) and default calendar (used for duration and dates roll-up onto grouping bands)
    while scheduling is the same, P6v7 has improved the conversion mechanism in the way that the set of conversion rates to be used for conversion inbetween units of time (h,d,w,m,y) for duration fields (OD,RD,etc) is now available at the calendar level.
    this way, all (task-dependent) activities using the same (activity) calendar will convert inbetween the above mentioned duration units using the same ratios, set at the calendar level. the admin setting is somewhat obsolete.
    conversions are more consistent with calendar definitions, but that still doesn't mean that lunch breaks, weekends, holidays or custom calendar exceptions, as defined for the applicable calendar, will be considered when converting an input of "2m" into "43d" as displayed in the Original Duration field.
    if calendar conversion set says 1m=172h and 1d=8h, 2m=43d from Jan till Dec or the end of time for that matter :)
    the fact is that "2m" changes within the year, "2d" can vary within a month, week, etc
    it is safe to say that 1h stays the same and is usually either working or non-working, throughout the schedule of your multi-annual project
    that is unless you really really need sub-units of 0.25h or 3h 3mn, start / finish dates & time, coffe breaks from 10:30 to 11:00 and such :)
    Edited by: Tibi on Mar 9, 2010 4:20 PM
    Edited by: Tibi on Mar 9, 2010 4:21 PM

  • Month calculations: DATE() vs EDATE()

    In a recent topic (Challenge to get a date correctly), I mentioned using the DATE function to calculate a date that is (for example) one month later than a given one. Specifically, if cell A1 contains the given date, then I suggested using this formula for a date one month later:
    =DATE(YEAR(A1),MONTH(A1)+1,DAY(A1))
    Yvan Koenig suggested instead using the simpler EDATE formula, here equivalent to:
    EDATE(A1,1)
    There is, as it turns out, more than simplicity in favor of Yvan's approach. While one might expect the two formulas always to produce the same results, they do not! This is easily seen by constructing the following three column table with a column header:
    1. In cell A2, enter the last day of the first month of this year (January 31, 2008 in the U.S. system, for example). In the cell below it, enter the last day of the second month of this year (Feburary 29, 2008, for example).
    2. Next, select both cells & use the circular fill handle, drawing down to fill the column with a year or so of last-day-of month values.
    3. Select cell B1 (a header cell) & enter in the formula bar & press return:
    =DATE(YEAR(A),MONTH(A)+1,DAY(A))
    4. Likewise, in cell C1 enter:
    =EDATE(A,1)
    Note that the B & C column values are sometimes the same, sometimes not. The same results occur if the "1" in both formulas is replaced with another number of months.
    What seems to be happening is the 'MONTH(A)+n' expression uses the number of days in the month of the "A" cell value as the basis for the 'n months later' calculation, which is not the convention usually used for such things as billing cycles. The EDATE formula follows the normal convention, & is thus the preferred choice for almost all uses imaginable ... unless perhaps you are the one being billed.
    This also applies to 'YEAR(A) + n' calculations.
    So, it would seem that any calculation involving the DATE(year, month, day) form with an arithmetic operator in the year or month element should be used only with great care, if at all.
    BTW, the comments about the month unit of calendar time having "no real purpose today" in http://www.cl.cam.ac.uk/~mgk25/iso-time.html may be of interest.

    I'm aware of the blue warning triangle appearing in these "overflow" situations; however, even when it does not, the results may be different -- for example, with a starting date of January 31st, adding one month in my long formula produces a month argument that is in bounds but (for 2008) yields a date 2 days later than with the EDATE method.
    I don't view this so much a bug as a consequence of the vague nature of the "n months later" or of the "month offset" concept. As the cited scholarly article points out, the concept of the months of the year are of somewhat obscure mystic origins, & there lengths were arbitrarily set, often for reasons more political than practical. Between the 1st & 28th day of any month, the concept is unambiguous -- it is the same numbered day in the other month, but for the 29th through 31st day of the month it is not, depending on the starting month.
    From what little I have been able to discover from casual research, the EDATE results are the standard more by custom than by any well-defined rule: what we mean by the offset references the first, last, or some near-the-end-of-the-month day number, whichever seems the most suitable at the time.
    I do not have Excel on my Macs, but since the functions are similar, I would be interested in learning how that application behaves with this table.

  • Fiscal Month/Year Date Calculations

    Hi Gurus,
    I am trying to create a fiscal year and fiscal month offset using filter advanced SQL in answers. The “Offset” should allow to define a period of time + or – from a given starting point in order to report on a period of time. For example the Current Month Offset - When the variable is defined and set-up in the “Time” drop down menu in Answers. You would select Current Month Offset and in the create/edit filter dialog the Current Month Offset column contains a value of 0 for the most recent loaded month of data, a value of -1 for the month prior to that and so on. By selecting the “Operator”, “is between” and “Value” -5 and “Value” 0 you would filter to display the last 6 months.
    I created the offset with calendar year using the Advanced filter and worked fine for if i need to change the year to what ever value
    (((YEAR(CURDATE())-YEAR(Time.Date)) * 12) + (MONTH(CURDATE())-MONTH(Time.Date))) * -1 = -1
    The issue comes when i create for Fiscal year and Fiscal month using filter advanced SQL it throws an error
    (((FISCAL YEAR(CURDATE())-FISCALYEAR(Time.Date)) * 12) + (FISCAL MONTH(CURDATE())-FISCAL MONTH(Time.Date))) * -1 = -1
    for fiscal year it throws an error below
    Error getting drill information: SELECT Time."Fiscal Year" saw_0, Time."Fiscal Year" saw_1 FROM "AAFES Procurement - Purchase Orders" WHERE Time."Fiscal Year" = (((FISCAL YEAR(CURDATE())-FISCALYEAR(Time.Date)) * 12) + (FISCAL MONTH(CURDATE())-FISCAL MONTH(Time.Date))) * -1 = -1
    Error Details
    Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <CURDATE>: Syntax error [nQSError: 26012] . (HY000)
    SQL Issued: {call NQSGetLevelDrillability('SELECT Time."Fiscal Year" saw_0, Time."Fiscal Year" saw_1 FROM "AAFES Procurement - Purchase Orders" WHERE Time."Fiscal Year" = (((FISCAL YEAR(CURDATE())-FISCALYEAR(Time.Date)) * 12) + (FISCAL MONTH(CURDATE())-FISCAL MONTH(Time.Date))) * -1 = -1')}
    Thanks
    Simmz

    Hi,
    Kindly refer the below link it may help you.
    http://obieeelegant.blogspot.com/2011/06/obiee-date-expressions-reference.html
    Thanks
    Deva

  • Calculate Month-to-Date in Obiee11g

    Hi,
    I'm using OBIEE11g, im facing a problem-
    Problem : Month-to-date  results of this month vs. Month-to-date results of previous month
    example: if Im in 12th February the calculation is *1st February to 12 February* also *1st January to 12 January*
    -Zia

    Hi
    I have an immediate requirement from my client as following.
    I have prompts : Year, Month,Quarter and Date between
    When the user selects an year --> then the headcount is calculated as following either Annulized/Monthlyor quarterly
    HC= Sum(headcount of each day in that selected year) / No of days in the year
    Similarly for Month,Quarter and date between.
    If this is computed then I can apply the same logic for FTE calculation.
    Any inputs or help greatly appreciated.
    thanks in advance
    hk

  • How to get the current month starting date and ending date by default ?

    Hello Creators,
    This is my requirement, kindly do the needful, Please dont gimme any links i've no access for other sites, gimme the right solution.
    My Requirement :
    Creation Date (VBAK-ERDAT) - Select Option. By default, the program should run for the current Month ie between the starting and ending date of the current month when the program is run. Today the date is 18th using sy-datum we can bring the current date by calling it in the initialization event, but the requirement is it should not give me the current date, it should only give me the month starting date and the end date. Kindly help.
    Thanks in advance ...

    DATA: gv_datum LIKE vbak-erdat.
    SELECT-OPTIONS: so_date FOR gv_datum.
    INITIALIZATION.
      CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
        EXPORTING
          iv_date             = sy-datum
        IMPORTING
          ev_month_begin_date = so_date-low
          ev_month_end_date   = so_date-high.
      so_date-option = 'BT'.
      APPEND so_date.
    START-OF-SELECTION.
    Hope this solves the issue. Don't forget to be generous
    Cheers,
    Sougata.

  • Select Record Between Date Gap-Oracle 11g, Windows 2008 server

    hello everyone,
    I have a sql query where I need to select only records with an 18 month gap between max(date) and previous date( no dates between max(date)
    and 18 month gap date), when I run the below query it should only select supid 130, not 120 (even though 120 does contain an 18 month gap date it also has a date that is less then the 18 month gap( '25-NOV-2012','DD-MON-YYYY').
    how would get the query to look back 18 months for the next date and evaluate the month_between.
    any help is greatly appreciated.
    example:
    create table supply(supID number(8), supply varchar2(20), supdate Date,supamount number(13,2));
    insert into supply values(100,'Tapes',to_date('01-AUG-2013','DD-MON-YYYY'),50.00);
    insert into supply values(100,'TV',to_date('01-APR-2013','DD-MON-YYYY'),250.00);
    insert into supply values(100,'Discs',to_date('25-DEC-2012','DD-MON-YYYY'),25.00);
    insert into supply values(120,'Tablets',to_date('25-AUG-2013','DD-MON-YYYY'),15.00);
    insert into supply values(120,'Paper',to_date('25-NOV-2012','DD-MON-YYYY'),35.00);
    insert into supply values(120,'Clips',to_date('20-NOV-2010','DD-MON-YYYY'),45.00);
    insert into supply values(120,'Binders',to_date('28-FEB-2012','DD-MON-YYYY'),25.00);
    insert into supply values(130,'Discs',to_date('25-JUL-2013','DD-MON-YYYY'),75.00);
    insert into supply values(130,'Calc',to_date('25-JAN-2012','DD-MON-YYYY'),15.00);
    insert into supply values(130,'Pens',to_date('15-DEC-2011','DD-MON-YYYY'),55.00);
       select * from supply p where to_char(p.supdate,'yyyy')='2013'
       and p.supid in(select s.supid from supply s where months_between(s.supdate,p.supdate)<-18)
         SUPID SUPPLY               SUPDATE    SUPAMOUNT
           120 Tablets              25-AUG-13         15
           130 Discs                25-JUL-13         75

    Something like this?
    select
    from (
    select
      supid
    , supply
    , supdate
    , supamount
    , lead(supdate) over (partition by supid order by supdate desc) ldate
    from supply
    where
    months_between(supdate,ldate) >= 18
    SUPID
    SUPPLY
    SUPDATE
    SUPAMOUNT
    LDATE
    130
    Discs
    07/25/2013
    75
    01/25/2012
    Ok. i see you want only he diff to max date.
    select
    from (
    select
      supid
    , supply
    , supdate
    , supamount
    , lead(supdate) over (partition by supid order by supdate desc) ldate
    , row_number() over (partition by supid order by supdate desc) rn
    from supply
    where
    months_between(supdate,ldate) >= 18
    and
    rn = 1
    Message was edited by: chris227
    extended

  • Current week/current Month/YTD data based on user response

    Hi
    I have one attribute request_created_date
    Based on this i want to create one more attribute which will have lovs as week(Request_created_date for current week),monthly(Request_created_date for current week),
    YTD(Request_created_date for current year to date).
    Now i want to use this new attribute (Having LOV as week/Month/YTD) as a report prompt so that user itself can select whether he wants to see
    week/month/YTD data in report.
    To Add to this :
    Req is something like this if user select week , Req_created_dates should be filtered for all the dates of cureent week.
    Req is something like this if user select month , Req_created_dates should be filtered for all the dates of cureent month.
    Req is something like this if user select Year , Req_created_dates should be filtered for all the dates of cureent year.
    How can i achieve this?

    Add One variable
    Time_Data ="Weekly"
    Create Input control (Radio Button)
    Use Custom LOVs (Add Weekly , Monthly , Yearly ).
    Set Default (Weekly).
    Now Create Another Variable
    User_Want = ReportFilter([Time_Data])
    Now filter your Report for week , Month or Year (as per Selection) using If else Statement .
    For eg.
    For Week
    [Created_Date] Between RelativeDate(CurrenDate();-7) And CurrentDate()
    For Month
    (Year([Created_Date]) = Year(CurrentDate())  And Month([Created_Date]) = Month(CurrentDate()))
    For Year
    (Year([Created_Date]) = Year(CurrentDate())

Maybe you are looking for

  • Is it possible to create a SHORT CUT key for a Workspace in CS 5.5 ?

    Is it possible to create a SHORT CUT key for a Workspace using In Design CS 5.5 ?

  • Linking an image file

    In DTP programs (and also MS Word) you can insert an image file as a link to the actual file in the disk, so the graphic is not embedded in the document, instead when the document is opened the file readed from the external source. This method have t

  • AirTunes with more than 5 Express

    Has anyone tried to manage AirTunes with more than 5 Airport Express Base stations at the same time? Apple says that not more than 5 bases are supported but I need to use at least 8 bases for a job. Thanks for the answers! Mac Pro, PBook G4 15", iBoo

  • Importing Illustrator CS6 File into Photoshop - Are they linked?

    I am teaching out of the Photoshop CS6 Classroom in a Book book and Chapter 8 talks about working with vector shapes and smart objects.  On page 227, under the Importing a Smart Object section, the following statement is made: You can import vector o

  • Mac is not finding the camera

    I am getting "No Camera is found." when I connect my iPhone4 to my macbook pro.