Calculate future dates

Am looking for either a javascript or formcalc that will run at the client level to calculate future dates based on input into a base date.
Example:
Input: 30 April 2005
Outputs:
Next Event: Monday, 15 May 2005 (base date + 15 days)
Next Event: Saturday, 29 June 2005 (base date + 45 days)

I don't have such script but I have a few tips for you if you want to write a script that will do just that.
- First, you can refer to the "input" date/time field by:
inputDate = DateTimeField1.formattedValue;
- You can then parse the date/month/year values
var theYear = inputDate.substring(0,4);
var theMonth = inputDate.substring(5,7);
var theDay = inputDate.substring(8 );
- Create a JS date object, useful for date manipulation.
var dateObj = new Date();
var baseDate = dateObj.getDate();
var baseMonth = dateObj.getMonth();
var baseYear = dateObj.getYear() + 1900;
- Now you can implement a function called
displayFutureDate(baseDate,baseMonth,baseYear,numberOfDays,outputObj)
I leave the detailed implementation up to you. It would be a good and fun exercise.
Good luck!

Similar Messages

  • Calculate future date in MM/dd/yyyy format

    Hi,
    I am trying to add a 56 months to a given date (MM/dd/yyyy string) and output the date in MM/dd/yyyy format.
    Here is my code:
                   SimpleDateFormat date = new SimpleDateFormat("MM/dd/yyyy");
                   date.parse("07/30/2000");
                   GregorianCalendar gc = new GregorianCalendar();
                   gc.add(Calendar.MONTH,+56);
                   System.out.println(date.format(gc.getTime()));  I tried to assign date.parse() to a Date but there is no fomat method on Date so to add months to the date. Could someone suggest me how to calculate a future date?

    thanks for looking, just found the answer:
                   SimpleDateFormat date = new SimpleDateFormat("MM/dd/yyyy");
                   Date dt = date.parse("07/30/2000");
                   GregorianCalendar gc = new GregorianCalendar();
                   gc.setTime(dt);         //this was missing
                   gc.add(Calendar.MONTH,+56);
                   System.out.println(date.format(gc.getTime()));

  • FM to calculate future date

    Hi,
    Im looking for a function module to add number of days ( working days only ) to a given date and return me the resultant date.
    For example, input date 25.02.2009. I need to add 5 working days and the resultant date will be 04.03.2009.
    Thanks for the help

    Hi,
    The FMs of your interest would be:
    DATE_IN_FUTURE - Calculates a future or past date
    WDKAL_DATE_ADD_FKDAYS - Number of working days in a date range
    HOLIDAY_GET - All holidays in a factory calendar
    DATE_CHECK_WORKINGDAY - Determines if a single date is a working day
    There are no direct FM as far as i know. You can use the above FMs and write logic accordingly to get your desired result. Do search on the above FMs for their details.
    Cheers.

  • FUnction Module to Calculate future date after 'x' years

    Hi Gurus,
    Can anyone tell me the Standard Function Module which will take today's date as i/p & return the date after 10 years.
    e.g say input date is 18.05.2010 & input year is 10.
                 output = 17.05.2020
    Regards,
    Rohit.

    why would it be in 10 years 17.05.2010 and not 18.05.2010 ??
    which logic do you want to use to calculate the 10 years after ?
    kind regards
    arthur

  • How to calculate future date

    I have used the following code from http://forums.adobe.com/message/2077238#2077238.   But it does not seem to work when straddling years.
    I want the use to enter a date in DateTimeField1, then the date in DateTimeField2 to add 6 months to DateTimeField1
    Then DateTimeField3 to equal 4 months from DateTimeField 2.  Then DateTimeField4 to add 6 months to DateTimeField3
    DateTimeField1 = user enter
    DateTimeField2 = util.printd("mm/dd/yyyy", DateUtils.addMonth(new Date(Date.parse(DateTimeField1.formattedValue)),5));
    DateTimeField3 = util.printd("mm/dd/yyyy", DateUtils.addMonth2(new Date(Date.parse(DateTimeField2 .formattedValue)),4));
    DateTimeField4 = util.printd("mm/dd/yyyy", DateUtils.addMonth(new Date(Date.parse(DateTimeField3.formattedValue)),5));
    function 
    addMonth(date, months){
    var year = date.getFullYear();
    var month = date.getMonth();
    var day = date.getDate();month =  ((month + months - 1) % 12) + 1;
    year += parseInt(month / 12);
    var days = daysInMonth(month, year);
    return new Date(year, month, days);}
    function
    addMonth2(date, months){
    var year = date.getFullYear();
    var month = date.getMonth();
    var day = 1;month = ((month + months - 1) % 12) + 1;
    year += parseInt(month / 12);
    return new Date(year, month, day);}
    function daysInMonth(month, year) 
     return 32 - new Date(year, month, 32).getDate();}
    When I enter 01/01/2010 in DateTimeField1, the following is that results:
    DateTimeField2 = 06/30/2010
    DateTimeField3 = 10/01/2010
    DateTimeField4 = 03/31/2010
    The desired result is:
    DateTimeField2 = 06/30/2010
    DateTimeField3 = 10/01/2010
    DateTimeField4 = 03/31/2011

    Hi,  I'm not sure I understand the result required here.  Wont 6 months on from 01/01/2010 be 01/07/2010, then 4 months be 11/01/2010 and another six months be 05/01/2011.  Your desired results have gaps of 180 days, 93 days then 181 days.
    Not sure why the script isn't working for you, maybe you should try Date.parse(DateTimeField1.rawValue).  The rawValue will always be in yyyy-mm-dd format, where the formattedValue will vary depending on locale and display patterns.
    Regards
    Bruce

  • 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.

  • Issue While Terminating a Service Contract with future date

    Hi CRM Gurus,
    We are in Oracle EBusiness Suite version R12 (12.1.3) and implementing service contracts for a client.
    Please help us with the following issue that we are facing while terminating  a service contract line with future date (end of the month).
    Example :
    A Contract 123 with 10 months of duration (Start Date:01-JUL-2013 and End Date: 30-APR-2014) has a service line 1.0 with unit price as $50 for a period of 10 months .The billing schedule is set for 10 months with each month for $50.
    The create main billing is run for the month of Jul 2013 and Aug 2013 and is sent to AR.Now we want to terminate the contract line with 30-Sep-2013 as termination date without any credit back to the customer so that we want to charge for month of Sep as well for $50.
    When we give 30-Sep-2013 as termination date and terminate the line, the billing schedule refreshes with $50 for Jul1-Jul 31 and $50 for Aug1-Aug31 and $48.39 for Sep1-Sep 29 instead of  30-Sep which is the termination date that we see on the line.
    The requirement is that we want to have the  billing for $50 even for the month of Sep,but the system only calculates for $48.39(which is 1 day minus) for the month of Sep. When we give Oct 1 as termination date ,then we get the schedule dates and amounts correctly i.e. 01-Sep to 30-Sep for $50.
    How do we achieve to bill for $50 when we put 30-Sep-2013 as termination date ? I see that the regular termination process does not consider timestamp while providing the termination date.
    Is this a bug or is there a patch for this or is there a workaround for this other than providing 01-Oct as termination date ?Please help.
    Regards,
    Sandeep Gorla

    Update the Ar Interface Table with  value 50$ for that record, before the Invoice gets created.

  • UCCX 8 Calculate a date

    Hello there,
    i don't know if it is really possible. But i was looking for the moveable holiday solution. I read always about the holiday script, that has a XML file as base for the holiday dates. But i want to calculate them on my own. I don't want the customer to change always the XML file.
    In germany we have a couple of holiday dates that are not fixed every year (like easter). It is not really nice to edit the XML file every year for the new dates. Someone of you will say: "Put the holidays for the next 10-30 years into the script!".
    Yes that can i do, but i will automate this
    So my question, has anyone tried something like that? I'm at the point that i don't know how to calculate with dates. Here a example:
    To calculate the next holiday, i have the easter sunday date calculated. Like 2011/24/04.
    The next holiday is 49 days in the future. So i have to add 49 days to the date of easter. I hope you see my problem. How can i calculate this to be aware of the month.
    Has anyone a idea? All posts are welcome!!!
    Christian

    Hi Koen,
    for the Easter, i googled a little bit around and found a couple of formulas to calculate the Easter Sunday. Here is the calculation:
        Given is year
        int c;
        int i;
        int j;
        int k;
        int l;
        int n;
        int EasterDay;
        int EasterMonth;
        string EasterDate;
        c = year / 100;
        n = year - 19 * ((int)(year / 19));
        k = (c - 17) / 25;
        i = c - c / 4 - ((int)(c - k) / 3) + 19 * n + 15;
        i = i - 30 * ((int)(i / 30));
        i = i - (i / 28) * ((int)(1 - (i / 28)) * ((int)(29 / (i + 1))) * ((int)(21 - n) / 11));
        j = year + ((int)year / 4) + i + 2 - c + ((int)c / 4);
        j = j - 7 * ((int)(j / 7));
        l = i - j;
        EasterMonth = 3 + ((int)(l + 40) / 44);
        EasterDay = l + 28 - 31 * ((int)OsterMonat / 4);
        EasterDate = EasterDay + "." + EasterMonth + "." year
    This calculation did i in some SET Steps. Then i put the EasterDate in a Variable String. Works perfect.
    But the calculation of the movable holidays is more complex as i thought. So as you say, i try to do this in Java. But i did not know anything about Java (
    I will try to understand you example and work on this to do what i will ))
    Greets
    Christian

  • Provisioning a user in future date

    Hello,
    Creating a new user and provisioned to OID work properly.
    Now I would like to create a user with start date in the future. OIM when the value USR_START_DATE is on the future it update the USR_PROVISIONING_DATE too on the same future date but not execute the provisioning to OID and the USR_STATUS is "Disabled Until Start Date"
    If there any way to update the USR_START_DATE with a different USR_PROVISIONING_DATE and do the provioning as normal and keep USR_STATUS as Active.
    thanks
    TG
    Edited by: TG on 1-Nov-2010 9:48 AM

    Hello again,
    i'm using the Thor.API.Operations.tcUserOperationsIntf.createUser((java.util.Map arg0).
    arg0 will contain USR_PROVISIONING_DATE=today date and USR_START_DATE = to the future date.
    I apply what your propose and push the USR_PROVISIONING_DATE=today date and put it on the pre-insert in Users form.
    sorry it did not work, it change the value in USR_PROVISIONING_DATE to put the USR_START_DATE value and didn't provisioned
    thanks
    TG
    Edited by: TG on 1-Nov-2010 10:47 AM

  • Purchase order error with future date

    Hi,
    Here one scenario like
    We have created a sales order VA01-->Pur. Order ME21N with current date i.e., 05.09.2008. System able to post perfectly and post MIRO, cutomer invoice and finally released to accounting.
    Now, same sales order VA01-->Pur. Order ME21N with future date i.e., 05.09.2009. System threws error message "Account requires an assignment to a cost object".
    Here my question is, why system is asking this assignment if i gave future date(05.09.2009) and why system is not asking if i gave current date(05.09.2008) ? remaining all are same except date
    Looking forward your comments/thoughts
    thansk
    anifi

    Hi,
    Thanks for your reply
    regards
    Edited by: Anifi on Sep 22, 2008 6:18 AM
    Edited by: Anifi on Sep 29, 2008 2:05 PM

  • How to disable the future dates in Date pick calendar - SQL Server Reporting Services

    Hi All, 
             I have a scenario to run the report only for the Past days, and i have datepick calendar as a parameter for selecting Start Date and End Date. I want to control the Users by not to select the Future Dates in the End Date. In Other Words, the user should not select beyond the Current Date,
    Is there any way for me to control it. Advance Thanks
    Regards,
    Sundarrajan.

    Hi
            Here is a solution for ur problem: put the below code in the script, and the add
    OnClientDateSelectionChanged="checkDate"
    in the calenderExtender... u ll get the answer nicely.. Happy coding..
    <script type="text/javascript">
    function checkDate(sender,args){
    alert("You cannot select a day greater than today!")
    sender._selectedDate = new  Date();
    sender._textbox.set_Value(sender.selectedDate.format(sender._format))
    }</script>

  • 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

  • Future date not to be allowed in the tabular form

    Hi,
    I have a tabular form with 3 columns.. the first column name is DATE, the user is not allowed to enter a future date or a date greater than the sysdate, so as soon as the date value is entered I have to generate a javascript/dyanamic action that throws error... I don't want the alert message to pop up when the submit is pressed, when the user moves the cursor to the next column, error should be shown. Is this possible. I am using APEX 4.0

    Hello Suzi,
    I’m afraid I won’t be able to walk you through this issue as I need to leave the office, however I have some remarks for you.
    First, if you intend to practice JavaScript you should really find the time to learn and understand it. I can promise you it will worth your while, otherwise you’ll just waste a lot of time.
    Secondly, The values of the APEX items you are retrieving using JavaScript are strings. So, in your current code you are actually comparing two strings and not dates.
    Next. When you are validating your data using JavaScript you have to make sure that the user will take the necessary measurements to fix the problem. For example, you must place the cursor back in the offending field. Using the following:
      wwv_flow.f04[1].focus(); will set the cursor in the first cell of the ‘f04’ column. This code also suggest that wwv_flow.f04 is actually a JavaScript array that holds references (object pointers) to all the cells in the ‘f04’ column. You can go through them using a simple loop.
    You should also not use the onchange event in this case. Imagine that after your first error alert, and setting the cursor back to the offending field, the user just press tab to move to the next field. This time around, the onchange event will not be fired (as the value of the field has not changed) and you lost your validation effect. To force the JavaScript validation to fire every time you should use the onblur event.
    That’s all for now :)
    Regards,
    Arie.
    &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    &diams; Author of Oracle Application Express 3.2 – The Essentials and More

  • A dynamic "future" date stamp

    Hello folks,
    I am looking to insert a future date automatically in a dynamic stamp. That is, I would like to be able to have the stamp automatically add X days to the current date. I have seen a lot of JavaScript forums, tried many of the proposed solutions, but have yet to find something that works for my dynamic stamp. Currently my stamp looks like this:
    event.value = (new Date()).toString();
    AFDate_FormatEx("mmmm d, yyyy");
    Amy help would be greatly appreciated. Thanks!

    Thanks for the suggestion.  I gave this a shot, and it simply displays today's date:

  • Future Date Restriction in Transaction J2I5

    Hi,
    Is there a possibility to restrict "Excise Register Extraction" for Future Dates in J2I5 T code?
    Please assist on this...

    Issue resolved by ABAP changes

Maybe you are looking for