Calculate End Date

Hi,
I have 3 fields Start Date (Date Type), Term Length (Number) & End Date (Date Type). The user enters a start date and the contract term length in months, I need to calculate the end date.
For e.g. *09/12/2012 + 5 = 02/12/2013* -- -- NOT+ -- _09/17/2012_.
Basically add the number of months to the date and calculate the end date, but the default in CRMOD is adding the number as no. of days not month.
Is there any way I can do this using workflows. (I need the data displayed on the layout).
I thought of using the "Month" function to extract the value and add the no. of months, but it threw an error that it cannot work with 1 parameter.... I assume it is reporting only function and will not work in workflows. Is there any way/logic by using Julian Day/Month or some other function to do this calculation?
If not possible using workflows, as a last resort is it doable using reports?
Thank You

Gaurav,
Try this :
Create a Workflow and use the below expression on the field you want to update
Expr:- [<StartDate>]+[<TermLength>]*30
30 is the number of days in a month, this is a simple approach. If you want to use the actual number of months (which I think is your requirement) from that start date to the end date based on the number of months selected in Term Length, you will have to so some more If's and else, use the IIf function to validate this.
Ex: IIf(Month value of Start date is 1/January and the number of months selected in term length is 5 then you will have to build your logic around that to get number of months in each of those 5 months and use the sum of that in the code above.
Good Luck!
Royston

Similar Messages

  • How to Calculate End-Date for a given Startdate in business hours without holidays

    Hello Experts,
    I need to create a plsql function where we need to determine end date for a task. For this, input will be only start date & number of hours allocated for that task. Based on this input we need to exclude Business hours & need to include only Business hours. and in the end we need to achieve the end date after the hour addition to the start date.
    Example : INPUT: 03-OCT-2013 12:00:00 PM /
                                  Hours Allocated 30 Hrs.
    Business Hours - 11 AM to 9 PM.
    So time starts from or Startdate is Friday 03-OCT-2013 12:00:00 PM. 
    So If I want to calculate the end-date by adding 30 hours to it, it should come WednesDay 09-OCT-2013 12:00:00 PM because I excluded Weekends & considered only business hours that is 11 am to 9 pm.
    I am not able to get any such guidance in Internet as most of the docs are having start & end date as input.
    Please help!
    Thanks in advance !!

    Hi,
    As Christ said, there's no nuilt-in Oracle function to tell whether a given DATE is a holiday or not, partially because there's so much local variation in holidays.  You can write a function like that (see http://forums.oracle.com/forums/message.jspa?messageID=3351081 ), but creating a table will be simpler and more efficient.
    I suggest creating a row for every date, whether it's a work day or not; that way, you can have variations in the schedule (e.g., schedule changes and
    partial holidays).
    CREATE TABLE  work_calendar
    (   dt  DATE       PRIMARY KEY
                       CONSTRAINT  work_calendar_dt
                           CHECK (dt = TRUNC (dt))
    ,   day_type       VARCHAR2 (8)  NOT NULL
                       CONSTRAINT  work_calendar_day_type
                           CHECK ( day_type IN ( 'HOLIDAY'
                                               , 'WEEKEND'
                                               , 'WORK DAY'
    ,   start_time     DATE
    ,   end_time       DATE
    ,   work_hours     NUMBER
    ,   work_hours_since_1970     -- or some point earlier than you'll ever need
                       NUMBER
    ,   CONSTRAINT  work_calendar_start_time
            CHECK ( TRUNC (start_time) = dt)
    ,   CONSTRAINT  work_calendar_end_time
            CHECK ( TRUNC (end_time) = dt)
    This will let you do a lot of the calculations you need without a function.

  • Calculate end date from inputs : start date and number of months

    Hello Experts,
    I have a start date and number of months from which i need to calculate the end date.
    For Eg: start date = 03-12-2008
                no. of months = 48
          Ans: end date = 03-12-2012
    Please help me.

    requirement is no different from what is stated in the previous thread.
    To elaborate further, I'm looking for some Function Module or some relevant alternative to calculate the future date.
    Future date is calculated using a start date input and No. of months.
    As stated in the example in my previous thread.
    For eg:
    Inputs to FM    : Start date        : 03-12-2008
                                    No. Of months : 48  months
    Output from FM: Future Date     : 03-12-2012
    Looking forward for your reply.

  • Urgent ! Exit code to calculate End Date (31/12/9999) to Current system Dat

    Dear All,
    I have a scenario where i need to calculate Position time hold by an employee in an organisation.
    I have 2 date Char ( DATE FROM & DATE TO), the problem is that is , If an employee is having
    2/3 position in an organisation its current position End Date is always 31.12.999 as its End date is
    not know. For previous position End Date is maintained.
    My requirement is to calculate Position hold time including Current position.
    I have created 2 Formula Variable on Date From & Date To,
    The issue is that Date To is having both Values Previous Position Date thats ok as its not 31/12/9999
    I am geting those values in Forumla in addition its also having Date For Current position as 31/12/9999
    which should be converdet in to current system date.
    I need to write a User Exit on End Date Forumla Variable which should only convert if Date = 31/12/9999
    else leave it as it.
    For EX,
    EndDate
    1/1/2005
    1/1/2006
    31/12/9999(Only this value need to convert as current system date and leave above valuse as it)
    Can any one please provide me the code for this, this is v urgent.
    Thanks V V much.
    Regards,

    Hi Dilek,
    I now understand what you were writing.
    I played around a bit and it still doesn't work like I want to.
    The really strange thing is when I adapt an existing (SAP - standard) dynamic action (for another IT)  the 'calculation part' is performed and with my own attempt it doesn't substract the day.
    0442              BEGDA     06     10     P     T001P-MOLGA='05'
    0442              BEGDA     06     20     I     MOD,0014,1539
    0442              BEGDA     06     30     W     P0014-ENDDA=P0442-BEGDA
    0442              BEGDA     06     50     W     P0014-VTROP='-'
    0442              BEGDA     06     55     W     P0014-VTRAN='1'
    0442              BEGDA     06     60     W     P0014-VTRZH='010'
    If IT0442 is created or changed, IT0014 with subtype/wagetype 1539 should be delimited with enddate = (startdate IT0442 -/- 1 day)
    If you can have a look whether I mak e an obvious mistake, it's appreciated.
    In the meantime I'll fiddle around as well at my end.....
    Thanks,
    Wilfred.

  • How to calculate first date and end date of this year in Query

    Hi Expert
    I want to calculate following dates with inputted date in query.
    I have no knowledge on ABAP and I just can create a query with simple logic.
    Could you teach me how to calculate following date?
    (If inputted date is April 12 2009)
    - First date of this year (Ex January 1 2009)
    - End date  of this year (Ex December 31 2009)
    - First date of last year (Ex January 1 2008)
    - End date of last year  (Ex December 31 2008)
    - First date of this month (Ex April 1 2009)
    Thank you!
    Take

    HR_JP_MONTH_BEGIN_END_DATE   use this FM to get the begin and end date of the Date you are passing. eg when u give input as 04/12/2009, it will return
    04/01/2009 as begin date
    04/30/2009 as end date
    pass the Year in this FM HR_E_GET_FISC_YEAR_DATES, you will get the Fiscal year Begin and End Dates
    Abh

  • Calculate Start and End date in Connect By -- When Hirerchy Changes

    /* Formatted on 5/20/2013 9:53:00 AM (QP5 v5.115.810.9015) */
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    Hello , Can some one Please help me or Guide me in calculating Start and End dates for the below logic
    I want to calculate the Manager Hirerchy for the given Agent.
    Then Below Query is working fine and its giving me the desired results
    But when there is a change in the Manager Hirerchy or Manager gets Promoted
    Then i need to calculate the start date and end date.
    CREATE TABLE PERSON_DTL
      SID                 VARCHAR2(10 BYTE),
      EMP_MGRS_ID         VARCHAR2(10 BYTE),
      START_EFFECTIVE_DT  DATE,
      END_EFFECTIVE_DT    DATE
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
    Values
       ('M100', 'M107', TO_DATE('05/20/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
    Values
       ('M101', 'M102', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/18/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
    Values
       ('A100', 'M100', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
    Values
       ('M100', 'M101', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/18/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
    Values
       ('M107', 'M102', TO_DATE('05/20/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
    Values
       ('M102', 'M103', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
    Values
       ('M103', 'M104', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
    Values
       ('A101', 'M105', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
    Values
       ('M105', 'M106', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    SELECT   CONNECT_BY_ROOT (b.sid) agent_sid,
                 TRIM (
                    LEADING ',' FROM    SYS_CONNECT_BY_PATH (b.sid, ',')
                                     || ','
                                     || b.emp_mgrs_id
                    PATH,
                 START_EFFECTIVE_DT Start_dt,
                 END_EFFECTIVE_DT End_dt
          FROM   PERSON_DTL b
         WHERE   CONNECT_BY_ISLEAF = 1
    START WITH   sid IN ('A101', 'A100')
    CONNECT BY   PRIOR b.emp_mgrs_id = b.sid
    This is the results that i am getting now.
    AGENT_SID    PATH                       START_DT    END_DT
    A100    A100,M100,M101,M102,M103,M104    1/1/2010    12/31/9999
    A100    A100,M100,M107,M102,M103,M104    1/1/2010    12/31/9999
    A101    A101,M105,M106                   1/1/2010    12/31/9999
    Results Required
    A100    A100,M100,M101,M102,M103,M104    1/1/2010    5/18/2013
    A100    A100,M100,M107,M102,M103,M104    5/20/2013   12/31/9999
    A101    A101,M105,M106                   1/1/2010    12/31/9999

    May be this..
    SQL> select agent_sid,max(path) path,max(start_dt) start_dt,
      2         min(end_dt) end_dt
      3  from
      4  (
      5    select agent_sid,path,start_dt,end_dt,
      6           sum(flg) over(order by rn) sm
      7    from
      8    (
      9      select agent_sid,
    10             path,
    11             start_dt,
    12             end_dt,rn,
    13             case when path like lag(path) over(order by rn)||'%' then 0 else 1 end flg
    14      from
    15      (
    16        SELECT   CONNECT_BY_ROOT (b.sid) agent_sid,
    17                 TRIM (
    18                    LEADING ',' FROM    SYS_CONNECT_BY_PATH (b.sid, ',')
    19                                     || ','
    20                                     || b.emp_mgrs_id
    21                 )
    22                  PATH,
    23                 START_EFFECTIVE_DT Start_dt,
    24                 END_EFFECTIVE_DT End_dt,rownum rn
    25        FROM   PERSON_DTL b
    26        START WITH   sid IN ('A101', 'A100')
    27        CONNECT BY   PRIOR b.emp_mgrs_id = b.sid
    28      )
    29    )
    30  )
    31  group by agent_sid,sm
    32  order by agent_sid;
    AGENT_SID  PATH                                     START_DT  END_DT
    A100       A100,M100,M101,M102,M103,M104            01-JAN-10 18-MAY-13
    A100       A100,M100,M107,M102,M103,M104            20-MAY-13 31-DEC-99
    A101       A101,M105,M106                           01-JAN-10 31-DEC-99Edited by: jeneesh on May 20, 2013 7:54 PM
    Not thoroughly tested.And not sure whether an easy way exists..

  • Calculate the working days having the start and end dates only

    Hi,
    Can BIP be able to calculate the working days having the start and end dates only? It is like the NETWORKDAYS function in Excel. (i.e. excluding weekends and holidays).
    Thanks.

    Not out of the box.
    But You could extend your BIP functions
    Look at here:
    http://blogs.oracle.com/xmlpublisher/2009/05/bip_by_extension.html
    Based on that what you need is similar to the following Java code:
    http://objectlabkit.sourceforge.net/
    regards
    Jorge A.

  • Week End Date calculates dates in table issues

    Greetings All,
    I'm working on a LiveCycle Designer ES4 document that has a Week Ending Date MM-DD-YYYY (which need to always be a Saturday) selected in a subform.
    I need this Week End Date to then calculate and display the selected Saturday and the previous days in a seperate subform with a table. The days need to display in seperate columns below the header.
    This is what I have so far:
      TopmostSubform.Page1.Requestor.WeekEndDate::exit - (FormCalc, client)
    var endDate = Date2Num($,"MM-DD-YYYY")
    var dayOfWeek = Num2Date(endDate, "E")
    if (dayOfWeek <> 7) then
       xfa.host.messageBox("Ending date must be a Saturday")
       $ = null
       xfa.host.setFocus("$")
    endif
    Page1.#subform[1].InputTable.Row1[0].Date7 = Num2Date(endDate - 0, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date6 = Num2Date(endDate - 1, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date5 = Num2Date(endDate - 2, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date4 = Num2Date(endDate - 3, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date3 = Num2Date(endDate - 4, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date2 = Num2Date(endDate - 5, "DD")
    Page1.#subform[1].InputTable.Row1[0].Date1 = Num2Date(endDate - 6, "DD")
    However I keep getting an error on the WeekEndDate when selecting a Saturday.
    Does anyone have any idea what I'm doing wrong?
    Thank you for any help!
    -Michelle

    Well, I never got an answer from the forum here, but to help out others - here is what I did:
    This was all done in FormCalc.
    The object WeekEndDate Date/Time Field has a set pattern date{MM/DD/YYYY} in the Object Field Pattern in LiveCycle.
    BUT, the Scripting required the pattern to be YYYY-MM-DD
    Why? I have no flipping clue. It won't work any other way for me.
    Also this item requires a Saturday Date to be chosen. Days of the week are designated by numbers (Sunday = 1, Monday = 2, etc.)
    The line <>7 means that if the day is not Saturday (7) then the error message "Ending date must be a Saturday" will appear.
    This is the Exit event Script:
    TopmostSubform.Page1.Requestor.WeekEndDate::exit- (FormCalc, client)
    var endDate = Date2Num($,"YYYY-MM-DD")
    var dayOfWeek = Num2Date(endDate, "E")
    if (dayOfWeek <> 7) then
         xfa.host.messageBox("Ending date must be a Saturday")
         $ = null
         xfa.host.setFocus("$")
    endif
    The individual Date cells are set to a Date/Time Field with no pattern set in the Object Field Pattern in LiveCycle.
    The coding below designates a MM/DD pattern.
    Each individual field has it's own scripting, with the appropriate minus calculation  - #
    This is the Calculate script for the Sunday cell:
    TopmostSubform.Page1.#subform[1].InputTable.Row1[0].Date1::calculate - (FormCalc, client)
    var dateNum = date2num(TopmostSubform.Page1.Requestor.WeekEndDate.formattedValue,"MM/DD/YYYY") - 6
    $.rawValue = num2date(dateNum,"MM/DD")
    And the Saturday cell, that needed to display the Saturday End Date has the following Script, with NO minus number:
    TopmostSubform.Page1.#subform[1].InputTable.Row1[0].Date7::calculate - (FormCalc, client)
    var dateNum = date2num(TopmostSubform.Page1.Requestor.WeekEndDate.formattedValue,"MM/DD/YYYY")
    $.rawValue = num2date(dateNum,"MM/DD")
    Why did I include this all here?
    Because this whole project has been gawd-awful, and hopefully these insights can help another struggle forms designer understand the FormCalc scripting used.
    -M

  • Need a FM for gettng starting & ending date based on the settlement period

    Hi,
    I have to filter a database table based on the settlement period( IDENT3 ) and the field available is of date field. Can anyone give me a function module by which can calculate the starting date and ending date by providing the settlement period ( eg. AM- Monthly, AQ- Quarterly, AJ- Annually,  etc ) and date.
    Thanx in advance.
    Regards,
    Sumanth.

    Hi Sumanth,
    Please use the function module 'DATE_CONVERT_TO_FACTORYDATE' to get the start date and end date for the particular factory calender.
    For end date:
    CORRECT_OPTION                  +
    DATE                                       sy-datum
    FACTORY_CALENDAR_ID        Aq(quaterly)
    For start date:
    CORRECT_OPTION                  -
    DATE                                       sy-datum
    FACTORY_CALENDAR_ID        Aq(quaterly)
    According to sy-datum, it will calculate the Extreme  interval .
    Thanx,
    Zenthil.

  • Hyperion Planning dynamic forms based on start and end date across years

    Hi All,
    I have a requirement where i need to be able to view a form showing periods across years that are dynamically built depending on the start and end dates. If i have a start date of 01/11/2009 and an end date of 31/7/2013 i want to be able to view a form that shows all of the periods (Jan,Feb etc) in a form that is driven by these dates, in addition it will need to show the actual scenario up to the current month and the forecast from the current month to the end date. So basically if a user inputs the start and end dates the form will display the relevant periods driven by these dates.
    Any tips very much appreciated!

    Hello,
    This is difficult to realize, but you can get quite far with a workaround. The first question is, where do you want to input your selection of time periods? Assuming you have a webform with the complete timeline in months and years and you type in the start period and end period.
    Webforms have the option to suppress rows and columns.
    This can be extended with option of empty cells or not empty cells.
    You will need to apply your creativity on this.
    Put every month-year combination in a column and add the suppression.
    Calculate the timeline between start period and end period with a dummy member, so data exists for these and columns will show.
    Maybe you will need to copy the required timeline into a separate version for this, to avoid having periods which were outside the selection and still have data.
    I hope these hints help a bit in this challenge.
    Regards,
    Philip Hulsebosch
    www.trexco.nl

  • How to calculate start date of the week based on week number ?

    i need to get week number of the current date and based on that i need to calculate start date falling in the same week for last year.
    Eg. today is 31st week of year and 31st july date. so what will be the date on the 31st week of last year. i need the start date of that week.
    we can calculate the week number by select to_char(sysdate,'ww') from dual.
    DO we have a single line query for that or will it require writing a pl/sql block ?

    you can try following query
    it can be as inline but for more clean look and create it as select with include select
    with t as
    (select sysdate as dt from dual)
    select to_char(prev_year_dt - to_char(prev_year_dt, 'D') + 1, 'DD.MM.YYYY') as start_of_week from (select
    -- get day from prev year with the same week number
        case
               when to_number(to_char(add_months(dt, -12), 'WW')) > to_number(to_char(dt, 'WW')) then
                dt - (to_number(to_char(add_months(dt, -12), 'WW')) - to_number(to_char(dt, 'WW'))) * 7
               when to_number(to_char(add_months(dt, -12), 'WW')) < to_number(to_char(dt, 'WW')) then
                dt + (to_number(to_char(dt, 'WW')) - to_number(to_char(add_months(dt, -12), 'WW'))) * 7
               else
                add_months(dt, -12)
           end as prev_year_dt
      from t) t1good luck
    Sergii
    'Monday' is not first day of week in 100% ;)
    Edited by: Galbarad on Jul 30, 2012 11:00 PM

  • How do i calculate the dates in this scenario

    I have a situation here and i am not able to think through it
    there are 4 date columns in a table and i need to do something like below
    First Record start date is the start date, and end date is the next start date -1
    Next start date is next start date, and end date is the first end date of the record set of the end dates
    Next start date pervious end date + 1 and end date is the current end date
    Next start date is the current date and next end date is the current end date
    for example lets say we have a table like below
    CustomerID CustomerType CustomerEffDt   CustomerTrmDt CustNationalBgnDt CustNationalEndDt
    1                  National           2013-08-05        9999-12-31      
    2010-11-08            2011-11-02
    Now my question is, we would have to calculate the customer effective start and begin dates and national begin and end dates based on the above criteria
    we would have to create 4 rows based on the above scenario
    I am going mad and not able to think through this
    Can somebody help me
    Thanks

    Declare @Example table (CustomerID int, CustomerEffDt date, CustomerTrmDt date, CustNationalBgnDt date, CustNationalEndDt date, otherstuff varchar(99))
    insert @Example Select 1, '3/19/2014', '9999-12-31', '3/19/2015', '2/19/2016', 'first'
    UNION Select 2, '3/19/2014', '9999-12-31', '4/19/2014', '5/28/2014', 'second'
    UNION Select 3, '2013-08-05', '9999-12-31', '2010-11-08', '2011-11-02', 'first example by OP'
    Select CustomerID,Num
    , case When Num = 1 Then '1/1/1900'
    when NUM = 2 then CustNationalBgnDt
    when NUM = 3 then DateAdd(day, 1, CustNationalEndDt )
    when NUM = 4 then CustomerEffDt End as startdate
    , case When NUM = 1 then DateAdd(day, -1, CustNationalBgnDt)
    when NUM = 2 then CustNationalEndDt
    when NUM = 3 then Dateadd(Day, -1, CustomerEffDt)
    when NUM = 4 then CustomerTrmDt End as EndDate
    From @EXAMPLE
    Cross Apply (Select 1 as Num UNION Select 2 UNION Select 3 UNION Select 4) as Numbers
    order by CustomerID, Num
    /* --Your result
    1 1 1900-01-01 2015-03-18
    1 2 2015-03-19 2016-02-19
    1 3 2016-02-20 2014-03-18
    1 4 2014-03-19 9999-12-31
    2 1 1900-01-01 2014-04-18
    2 2 2014-04-19 2014-05-28
    2 3 2014-05-29 2014-03-18 ---***
    2 4 2014-03-19 9999-12-31 --****
    3 1 1900-01-01 2010-11-07
    3 2 2010-11-08 2011-11-02
    3 3 2011-11-03 2013-08-04
    3 4 2013-08-05 9999-12-31
    CustomerID StartDate EndDate
    1 1900-01-01 2014-03-18
    1 2014-03-19 2015-03-18
    1 2015-03-19 2016-02-19
    1 2016-02-20 9999-12-31
    2 1900-01-01 2014-03-18
    2 2014-03-19 2014-04-18
    2 2014-04-19 2014-05-28
    2 2014-05-29 9999-12-31
    3 1900-01-01 2010-11-07
    3 2010-11-08 2011-11-02
    3 2011-11-03 2013-08-04
    3 2013-08-05 9999-12-31
    ;with mycte as
    select CustomerID, dt,col,row_number() Over(partition by CustomerID Order by dt) rn
    ,row_number() Over(partition by CustomerID Order by dt DESC) rn2 from @Example
    cross apply (
    values( CustomerEffDt,'CustomerEffDt'), (CustomerTrmDt,'CustomerTrmDt')
    , (CustNationalBgnDt,'CustNationalBgnDt'), (CustNationalEndDt,'CustNationalEndDt'))
    d(dt,col)
    Select m1.CustomerID,
    Case when m1.rn=1 Then '1/1/1900'
    When m2.col='CustNationalEndDt' Then dateadd(day,1,m2.dt)
    Else m2.dt end as StartDate,
    Case
    when m1.rn2=1 Then m1.dt
    When m1.col='CustNationalEndDt' Then m1.dt
    else dateadd(day,-1,m1.dt) End
    as EndDate
    From mycte m1 LEFT Join mycte m2 on m1.CustomerID=m2.CustomerID AND m1.rn=m2.rn+1
    Order by m1.CustomerID, m1.dt

  • Deadline moniter - Dynamic latest start / latest end date and time

    Hi all,
    My requirement is to have the latest start and latest end time made dynamic. This is because each Personnel area or business unit has different requirements as to when they the notification and escalation to happen.
    For example -
    Business unit 1 wants escalation to happen after 5 days where as Business unit 2 wants escalation in 2 days itself.
    Any ideas here

    Hi,
    You can create a method in your BO to calculate the date for calculating deadline and pass it on to the workflow .....
    Calculate the date as per your requirement and later populate it in the deadline step using the EXP expression
    for eg. if you  have 5 days calculate the date as per 5 days and time 1 min etc...
    Regards
    Gautam
    Edited by: gautam maini on Aug 18, 2011 9:06 PM

  • Reduce Working Days by Emp Start and End Dates

    I'm banging my head trying to get this working. The set-up:
    DimResources table with various employee information including a Start and End Date.
    A Calendar table with FullDate, Year, Quarter....WorkingDays (1 for working and 0 for non-working) and WorkingDayNumber (working days increased by 1, weekends are not).
    Page View report with page view filters for Business, Role, Month, Week, Year.
    In the calculation the denominator is total working days for the period * 8. Works great. Further reduced by any submitted time off. Again, so far so good. The part I'm having trouble with is trying to further reduce total working days by
    the number of days the person wasn't available in a month, defined by the person's start or end date.
    The calculated field works great when only 1 person is selected. As soon as more than 1 person is selected or the slicer is cleared, an error is thrown.
    Any ideas on what is wrong or better ways to accomplish what's needed?
    TotalWorkingDays2CF=CALCULATE
     SUM(Calendar[WorkingDays]),
                    FILTER(Calendar,Calendar[WorkingDays]=1),
                    Calendar, DATESBETWEEN(Calendar[FullDate],SUM(DimResources[Start Date]),SUM(DimResources[End Date]))
    Error:
    <detail>
      <ErrorCode>rsErrorExecutingCommand</ErrorCode>
      <Message>Query couldn't run for dataset 'Tablix41DataSet'.</Message>
      <ProductName>Power View</ProductName>
      <ProductVersion>11.0.2150.3</ProductVersion>
      <MoreInfo>MdxScript(Model) (10, 27) Calculation error in measure 'Calendar'[TotalWorkingDays2CF]: An invalid numeric representation of a date value was encountered.</MoreInfo>
    </detail>
    Dennis DeRobertis

    ok, but this is not a running total but just a sub-total/grand-total
    so what you can do is the following:
    create two measures - first calculate the workdays per ressourcen and second use SUMX() to get the sub-/grand-total if multiple employees are selected (e.g. subgroups, groups,division, etc)
    WorkdaysRessource:=CALCULATE(
    COUNTROWS('Date'),
    FILTER('Date',
    'Date'[Date] >= CALCULATE(MIN('DimResources'[Start Date]))
    && 'Date'[Date] <= CALCULATE(MIN('DimResources'[End Date])))
    Workdays:=CALCULATE:=SUMX(
    'DimResources',
    [WorkdaysRessource]
    hth,
    gerhard
    Gerhard Brueckl
    blogging @ http://blog.gbrueckl.at
    working @ http://www.pmOne.com

  • Previous month end data for report

    Hi expert,
    I have to calculate previous month end data for my report.
    let say if user select 15 oct then he should be able to see 30 sept data.
    I have calander prompt.
    Thanks,

    Hi,
    Use presentation variable in date prompt.
    Apply sql filter(covert to sql) on report as date_column= TIMESTAMPADD(SQL_TSI_DAY,-DAYOFMONTH(date 'presntation_variable'),date 'presentation_variable')
    Refer : How to get LAST_DAY in obiee
    Regards,
    Srikanth

Maybe you are looking for

  • Problem with Photos in Camera Roll after 4.0.1

    Hello, I have a 16GB iPhone 3G. I updated to iOS4.0 the day it came out, and other than the slowness that everyone else was reporting, I didn't have any other issues. When I updated to 4.0.1, everything seems a touch better performance wise, but I fo

  • CS2 Installs successfully on Windows 7 but says invalid Serial Number

    Hi all, I just bought a new Dell with Windows 7.  When I installed the CS2 Premium software, it accepted my serial number and it also activated the software successfully at the end of installation.  When I check my online Adobe account, it shows the

  • How to display CPU temp in taffybar?

    I am using xmonad with taffybar. Recently I found out that I can find out the CPU temperature from taffybar like this: import System.Information.CPU2 cpuTemp = getCPUTemp ["cpu0"] However, I cannot find out a widget to display this quantity. Do someo

  • E6 - Mail for Exchange-invalid credentials

    Hi, need some help.... After configuring my nokia E6 for Exchange mail I keep receiving a message "mail for exchange-invalid credentials". I've checked all my credentials en configuration: they are correct.  I have tried the configurations on a Nokia

  • Mpeg2-dvd render color stripe on right side

    When I render HD720p video to mpeg2-dvd (23.976) I end up with a thin color stripe on the right side of the output video.  The stripe usually appears wherever I have a crossfade between images/videos.  How can I solve this problem>