Add x days to x date

Hi!
I am quite new at Acrobat and Javascript, which is a common lament on this discussion board from what I have read. But I need a little help!
I am creating a form in which the user needs to be able to input the estimated end date in the first field, and then input the number of days added in the next field, followed by an automatically calculated adjusted end date in the third field.
"OriginalDate" + "DaysAdded" = "NewDate"
Any help or links to help would be fantastic!!
Thank you!

Yes, but you would need to access the day of the week through the "getDaty()" method and add 2 for Satrudays and 1 for Sundays to bump the date to the next Monday.
// Custom Calculate script for NewDate field
(function () {
    // Get date entered into the OrigianlDate field
    var sDate = getField("OriginalDate").valueAsString;
    // Convert string to date
    var d = util.scand("mm/dd/yyyy", sDate);
    // Get the number of days added, as a number
    var days = getField("DaysAdded").value;
    // Add days to date
    d.setDate(d.getDate() + days);
   // possible adjustment for weekend
   var nAdj = 0;
    // get the zero based day of the week starting on Sunday
    var nDay = d.getDay();
    // test for Sunday or a value  day value of 0
     if(nDay == 0) nAdj = 1; // bump to Monday
    // test for Saturday or a day value of 6
    if(nDay == 6) nAdj = 2; // bump to Monday
   // adjust date
   d.setDate(d.getDate() + nAdj);   // adjust computed date by needed bump
    if (sDate) {
        event.value = util.printd("mm/dd/yyyy", d);
    } else {
        event.value = "";

Similar Messages

  • What is the best way to add a day to a Date object?

    I have come across numerous examples on adding a day to the CURRENT date, using the Calendar object. However, what I need to do is to add a day to a Date variable.
    Can someone tell me how to do that? I tried to set the value of my Date variable into the Calendar object, but, it appears that for the current JAVA version, they have deprecated the getYear(), getMonth() and getDay() methods for the Date class.
    Really appreciate your suggestions.
    Thank you in advance,
    SiowLing

    I haven't seen the OP express a concern over how to create/obtain the Date object (he could be using "new Date()" given the emphasis on "CURRENT"). Milliseconds is fine too if that's what you have (for example from a java.sql.Date).
    So the way to add a day to a Date object (the OPs original question) is to:
    - set the Date on a Calendar using setTime
    - add 1 to the DATE field of the calendar
    - get the Date from the Calendar using getTime
    Obviously you're right if the OP doesn't have Date object to start with, but just the "numbers" for year, month, day.

  • How to add one day to a Date?

    Hi,
    What is the simplest way to daa one day to a Date object?
    Thanks.
    Pengyou

    You use a database query just to add one day
    to a Date object? I wouldn't call that the "simplest"
    way at all.I was going to suggest firing off an email to the naval observatory and having them carry out the calculation, emailing the result back (maybe using JMS, not sure - web service possibly?) but the OP's way is simpler.

  • How do I add 364 days to a date?

    HI,
    I'm trying to add 364 days to a date on a form I've created.
    I've tried this method using form calc on the EndDate field but no success, just errors.
    EndDate=Date(InvoiceDate.getFullYear(),InvoiceDate.getMonth(),InvoiceDate.getDate()+364)
    Can anyone help please?

    The "InvoiceDate" is a character string and not the number of days from the epoch date for the "InvoiceDate". You first have to convert the "InvoiceDate" character string value to the number of days since the epoch date by using the "Date2Num()" function. Once you have the "InvoiceDate" as the number of days since the epoch date you can add the additional days before using the "Num2Date()" function to convert the adjusted number of days back to a date string.

  • How to add 2 days to a date field?

    How to add 2 days to a date field if a Saturday was selected on a different date field?
    Thanks

    I am attempting to add a date field and then have a another field add an amount to a box if the date is less than 30 days. Later I want to update the form to have the today's date is less than 10 days.
    Early Registration Fee is $10.00 if posted by February 25, 2008
    Late Registration Fee is $20.00 if posted by March 17, 2008
    It seems simple, but, when you get to be 71 years old, it seems difficult. Any help will be appreciated.
    Here is a link to the form I'm working on:
    http://www.aworldwide.com/Gideon/Convention_Registration.pdf
    I am using a trial version of Adobe Acrobat 8.
    Thanks,
    Andy Anderson

  • Add 60 days to a date

    Hi!
    I have a date object called "CLOSED_DATE" that I get from av database view. I would like to add 60 days to this date.
    If CLOSED_DATE = "20080501", the new date should be "20080629", that should be put into a variable (NEW_DATE) for futher use
    Thanks for all the help!
    Best regards
    Helge

    H helge
    1 Go to close date & right click on it.
    2 now on restriction select closing_date & again select it
    3 now select 'Set offset for variable" & add 60 in that column.
    the variable is ready to use. just save it
    Assign points if useful
    Cheers
    SM

  • Add 21 days to a date field in JSP

    Hi.
    How can I add 21 days to a String field containing a date value in JSP. I managed to get the string field without problem with the following codes :
    java.text.SimpleDateFormat formatdate = new java.text.SimpleDateFormat("dd-MMM-yy");
    java.util.Date currentTime_1 = new java.util.Date();
    String bDate = formatdate.format(currentTime_1);
    I would like to add 21 days to the field bDate.
    Please advice.
    Thanks.

    As far as I know we cannot manipulate on the formatted date i.e. on a string value. but you can add/deduct days from a date and then format
    it to get same result. you can try this out
    java.text.SimpleDateFormat formatdate = new java.text.SimpleDateFormat("dd-MMM-yy");
    java.util.Date currentTime_1 = new java.util.Date();
    Calendar cal = Calendar.getInstance();
    cal.setTime(currentTime_1);          
    cal.add(Calendar.DATE,21);          
    String bDate = formatdate.format(cal.getTime());          
    System.out.println("formatted date "+bDate);
    -Nagasree

  • How do you add 1 day to a date in BI answers

    Hi,
    I tried just putting (date column + 1) in the column formula but it wasn't having
    any of it. In SQL you can just put SYSDATE + 1. Is there any way of converting the
    date to a number, so I can do maths with it?
    Many thanks for any ideas,
    - Julian

    To Add One day to the column, place the following formula:
    TIMESTAMPADD(SQL_TSI_DAY, 1,Time."Day Date")
    similarly we can write the formulas using different intervals based on the date format in the column
    Here are the intervals :
    SQL_TSI_SECOND,
    SQL_TSI_MINUTE,
    SQL_TSI_HOUR,
    SQL_TSI_DAY,
    SQL_TSI_WEEK,
    SQL_TSI_MONTH,
    SQL_TSI_QUARTER,
    SQL_TSI_YEAR.
    Hope your question is answered.
    Thanks,
    -Amith.

  • Add one day to current date

    Hi ,
    can anyone tell me the logic for add one day to sysdate()?
    Thanks and Regards,
    Ranjith.

    Hi Ranjith K,
    you can use sysdate()+1 to increment the system date.
    I hope this will help you out.
    Regards,
    Akhileshkiran.

  • How can I add [# of days] to a date?

    edit::  Nevermind, I found the answer.  I'm using AS 2.0
    Answer: new Date(year, month, date+#)  where # is the # of days to add.
    Helpful link: http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/  (AS 2.0 & 3.0)
    Original question:
    The title is horrible, couldn't think of how to word it.
    Anyway, I want to know how I can take a date, add a few days to it, then display the resulting date.
    For example, today's date is 8/20/2010.  I want to be able to add 10 days to this and then display the result in a label or other output.
    The label would then read 8/30/2010.  If I wanted to add 15 days to today's date, the label would read 9/4/2010.
    Any help is appreciated, thanks!

    Another way of adding values to a date object is to set up constants, and this will make life easier if you do Date math frequently, or are adding to a date which is unknown until runtime (i.e., not neccessarily today's date).
                private var todayDate:Date = new Date();
                //One day, in milliseconds:
                private const oneDay:Number = 1000 * 60 * 60 * 24;
                private function addDaysToTheDate():void {
                    //The number of days you wish to add:
                    var daysToAdd:Number = oneDay * 10;
                    //Add the days to today's date:
                    var answer:Date = new Date(todayDate.time + daysToAdd);
                    Alert.show(answer.toDateString());

  • How to Add 20 days to a date field

    Dear All,
    I am struck badly on Date manipulation. If somebody has any ideaz on this let me know.
    I want to add some amount of days to system date and then compare it with another date.

    Hi capo9999!
    There are two class to easy and fast manipulate date variables: Calendar and GregorianCalendar.
    You must to read documentation about because there are many details to consider. Date variables has a special structure and do not confuse with "Date class" wich can be used with Calendar and GregorianCalendar.
    An example:
    Calendar today = new GregorianCalendar(); or
    Calendar now = Calendar.getInstance();
    create a new date structure with current date and to manipulate these variables there are methods to add an amount to components. Another example:
    now.add(Calendar.DAY_OF_MONTH, numDays);
    It's amazing to work this way.
    Best Regards.

  • Add 30 days to a date

    How do you add 30 days to a user inputed date parameter?

    Hi,
    Create Date Parameter.
    ->From select expert select that field.
    ->From dropdown select is in the period from second dropdown select Next 30 days
    ->Click ok
    ->Refresh report.
    Regards,
    Shweta

  • Add 90 days to a date field.

    Hi All,
    I have a form page in which i have a field called date. The requirment is like this whenever i come to this form page the date field should 1st check the sysdate and add 13 weeks or 90 days to it and display it there. It should be like this whenever user comes to this page the date field gets loaded like this and display there. Need help to do this.
    Thanks in advance.
    Regards

    But i want this field to be dynamic. This date field is date picker. If i select 15th May from date picker it should populate 14th august. Any suggestions on thisIs this concept of selecting one date and having a completely different one appear going to be clearly understood by users? From a usability/accessibility perspective it may be a better idea to use 2 items, with the initial selection being made in a date picker and the computed value appearing in a separate display/read-only item.

  • Add working days to a date excluding weekends and holidays

    Hi there,
    I need to write a function that will take a specified date and number of days to add as input parameters, and return the working day based on the number of days to add parameter, excluding weekends and any holidays held in a holiday table.
    Here is my function so far -
    CREATE OR REPLACE FUNCTION f_add_work_days(pd_date IN DATE
    ,pn_add_days IN PLS_INTEGER) RETURN DATE IS
    pd_in_date DATE := pd_date;
    ld_next_holiday DATE;
    ln_days_left PLS_INTEGER := pn_add_days;
    CURSOR cu_holiday(pn_date IN ge740.holdte%TYPE) IS
    SELECT pck_utility.f_dtcnv(g.holdte)
    FROM ge740 g
    WHERE g.holdte >= pn_date
    AND g.maint <> 'D'
    ORDER BY g.holdte ASC;
    BEGIN
    OPEN cu_holiday(pck_utility.f_dtcnv(pd_in_date));
    FETCH cu_holiday
    INTO ld_next_holiday;
    CLOSE cu_holiday;
    LOOP
    IF ln_days_left = 0 THEN
    EXIT;
    END IF;
    pd_in_date := pd_in_date + 1;
    IF pd_in_date > ld_next_holiday THEN
    OPEN cu_holiday(pck_utility.f_dtcnv(pd_in_date));
    FETCH cu_holiday
    INTO ld_next_holiday;
    CLOSE cu_holiday;
    END IF;
    CASE
    WHEN TO_CHAR(pd_in_date
    ,'fmDAY') = 'SATURDAY' THEN
    pd_in_date := pd_in_date + 2;
    ln_days_left := ln_days_left - 1;
    WHEN TO_CHAR(pd_in_date
    ,'fmDAY') = 'SUNDAY' THEN
    pd_in_date := pd_in_date + 1;
    ln_days_left := ln_days_left - 1;
    WHEN pd_in_date = ld_next_holiday THEN
    pd_in_date := pd_in_date + 1;
    ln_days_left := ln_days_left - 1;
    ELSE
    ln_days_left := ln_days_left - 1;
    END CASE;
    END LOOP;
    RETURN(pd_in_date);
    END f_add_work_days;
    I think there is something wrong/missing in the logic as I can't get it to cater for say a double bank holiday(25/26th Dec - if the input parameters are 24/12/2007 and 2, which should return the 28th but returns the 26th!!).
    I'm relatively new to PL/SQL and Oracle, so any help, advice, ideas would be greatly appreciated!
    thanks in advance

    smth like
    SQL> with holidays as (select to_date('10.06.2007','dd.mm.yyyy') h_dt from dual),
      2       par as (select to_date('08.06.2007','dd.mm.yyyy') dt, 2 add_days from dual)
      3  --
      4  select min(dt) needed_date
      5    from (select p.*,
      6                 h.*,
      7                 mod(to_char(dt, 'j'), 7),
      8                 sum(decode(mod(to_char(dt, 'j'), 7), 5, 0, 6, 0, 1)+--get rid of sat and sun
      9                     nvl2(h_dt, -1, 0)--check if the day is holiday
    10                     ) over(order by dt) s
    11            from (select dt + level dt, add_days
    12                    from par
    13                  connect by level <= 100) p,
    14                 holidays h
    15           where h_dt(+) = dt
    16           order by 1)
    17   where add_days = s
    18  /
    NEEDED_DATE
    13.06.2007
    SQL> ?
    Message was edited by:
    Volder
    PS What Oracle version are you on?

  • Add 5 days to baseline date using invoice date or posting date.

    Hi Everyone,
    I have been asked to test a script using ME2IN purchase order ,MIGO Goods receipt,Invoice MIRO and then test FB60 invoice to see if we can change the baseline date and increase it by 5 days.
    Please advise what i need to put in the test script and impact this can make to the business if this change is made. They needs 5 more days extra when the invoice is entered.
    Thanks
    Joe

    System gets base line date based on payment terms configuratin. You need to push baseline date back by 5 days manually. This will result your vendor item due date getting postponed by 5 days.

Maybe you are looking for

  • Word 2013 (Windows 7 64-bit) - Embed PDF as Icon Error

    We have a process where we embed PDFs into a table in a Word document as an icon. This worked for us in Word 2010, but as soon as we upgraded to Word 2013 we started getting an error message. "The program used to create this object is Package.  That

  • PDF opens in duplicate

    I am opening pdf's into illustrator to amend and save as AI files. They open as grey scale shapes which is fine, I then change the grey area fills to hatching then save as AI files. PROBLEM: Each PDF drawing opens in duplicate or triplicate on the sa

  • HT204088 Why is App Store saying a purchase has gone wrong

    Whenever I log in to the App Store it pops up saying "A purchase has gone wrong" but I havnt purchased anything. Now I can't download anything atall

  • Schema extension required in DMZ domain for IBCM?

    Do I need to extend the schema in my DMZ for IBCM?  I'll be managing DMZ servers, as well as laptops that move between the internal environment and the Internet.  The DMZ will only have an MP,DP and SUP.

  • When will Sweden get the new v20 firmware for N97?...

    OK, third attempt. This time I will not make any harsh comments directed at Nokia as they have threatened to remove my account. Please, please, pretty please with sugar on top, when will you release the v20 firmware for unbranded Swedish N97? I would