Click event to add (or subtract) a day to a date field

I have a form that is giving me a little trouble. I want to be able to input a start date in one field, then input a number of days in another field, and then have it calculate a date that is that number of days away from the start date. The form is actually working ok for the most part, but there are a couple of issues I'm having.
1. The end date is not calculating immediately upon exiting the number of days field. You have to tab all the way back to the start date and only when you exit that field does it calculate the end date. I need it to calculate when you exit the number of days field.
2. I have added a little (+) and (-) button to be able to increase or decrease the date by one day. This works, but the problem is, I want to do this in the background. Meaning, I want the calculated date to change, but the # of days field to not change.
So say I enter 12/1/2010 in the start date. Then I enter 1 in the # of days field. When I tab to the Calculated date field, it should immediately change to 12/2/2010. Then, if I click (+), the Calculated date field should go up to 12/3/2010, but the # of days field should stay at 1.
I've uploaded a sample of what I have figured out so far here:
https://acrobat.com/#d=v4c4KKdj0hesicxO8yO1pw
Thanks so much for any help I can get on this!
Jo

I think this is what you are after. I moved the logic to the calculate event of the target date and added a numeric field to hold the result of adding/subtracting (called 'delta').
// form1.#subform[0].date2::calculate - (FormCalc, client)
var date1 = Date2Num(date1.formattedValue,"MM/DD/YYYY")
$.rawValue = Num2Date(date1+days+delta,"MM/DD/YYYY")
You could make 'delta' hidden.
Steve

Similar Messages

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

  • 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 Days to a Date field

    Hi all,
    I have the following requirement:
    I have a date field 0calday and the user would like to add a specific no.of days to it, like for example 10 or 15 days. Then we use this computed date field in calculations in the query. Could you please help and let me know how we can no.of days to a date field? And also how we can compute no.of days between two date fields?
    Regards,
    Ashmith Roy

    Hi Ashmith,
        When the user enters both date and no. of days, and if you want to calculate no of days from the user entered date I think you can go for an exit where you can use the available function module which calculates the no of days from starting of the month for the given date. Then you can add up the days entered by the user and use another available function module which converts it to the dat format again based on the given days and the old date. I don't remember the function module names but i am sur ethey are available.
    If the above thing is made possible then I think getting no of days between two dates is not a problem. Well i hope this will help you.

  • Add days to a date field on adobe form

    Hi,
    I have to add 15 days to a date field how i do that on javascript or formcalc?
    Thank you in advance.
    Miguel

    Hi,
    The below is in js code.
    I had a caluclated date time field on the screen which displayed the current date.
    The below code will just add 15 days to the day part of the date.
    for moving it to month if its more than 31 is to be handled by you.
      var valArray = this.rawValue.split("/");
      var newDate = valArray[1] + 15;
      var actualVal = Date.parse(newDate+"/"+valArray[0]+"/"+valArray[2]);  
    var dateType=new Date(actualVal);
    this.rawValue = dateType;
    Hope this helps you out, let me know if you need any more info.
    Cheers,
    Sai

  • Working days between two date fields and Changing Factory Calendar

    Hi,
    I have to calculate working days between two date fields excluding the weekends and public holidays for Switzerland.
    I have written the routine using factory calender and its working fine except for two problems now:
    1. If any one of the date field is empty then teh rsult should be zero.
    2. And the below code is working from 1996 but my cleints wants it to work for years before 1996 as well.
    I also tried to change the Start date in SCAL for factory calendar but it says enter values between 1995 to 2020.
    I am new to ABAP. Please help me how i can achieve these for below code.
    DATA: IT_HOLIDAYS type TABLE OF ISCAL_DAY,
          IS_HOLIDAYS TYPE ISCAL_DAY.
    DATA: T_DATE TYPE SY-DATUM,
          P_DATE TYPE SY-DATUM.
    DATA : X_DATE(4) TYPE C.
    DATA: CNT TYPE I.
    REFRESH : IT_HOLIDAYS.
    CLEAR : IT_HOLIDAYS.
    T_DATE = SOURCE_FIELDS-/BIC/ZCCCHP812.
    P_DATE = SOURCE_FIELDS-/BIC/ZCCCHP810.
    CALL FUNCTION 'HOLIDAY_GET'
    EXPORTING
    HOLIDAY_CALENDAR = 'CH'
    FACTORY_CALENDAR = 'CH'
    DATE_FROM = P_DATE
    DATE_TO   = T_DATE
    TABLES
    HOLIDAYS = IT_HOLIDAYS
    EXCEPTIONS
    FACTORY_CALENDAR_NOT_FOUND = 1
    HOLIDAY_CALENDAR_NOT_FOUND = 2
    DATE_HAS_INVALID_FORMAT = 3
    DATE_INCONSISTENCY = 4
    OTHERS = 5.
    DESCRIBE TABLE IT_HOLIDAYS LINES CNT.
    X_DATE = T_DATE - P_DATE - CNT.
    RESULT = X_DATE.
    Please help
    Regards
    Zabina
    Edited by: Syed786 on Nov 2, 2011 9:15 AM

    Hi Zabina,
    Try this function module  'DURATION_DETERMINE'.
    Give the factory calendar and unit as DAY
    With regards,
    Rajesh

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

  • Add 365 or 366 days to selected date

    Hi All.
    I have form with two date field. The field EffectDate used  to enter random date and second is ExpDate to get date on one year late. How to get correct date on ExpDate field if differeence between dates possible 365 or 366 days. I will appreciate for brief explaination with sample.
    Thanks.

    Hi Paul,
    I modified code TextField1.rawValue = TextField1.rawValue + 365
    to TextField1.rawValue = TextField1.rawValue + 365 * 24 * 60 * 60
    I enter in EffectDate 08/30/2010 and get in ExpDate field wrong date like 4/19/8353. How to fix it? How to make ExpDate field empty if EffecDate is empty?
    Thanks.

  • Can I create a field that calculates number of days from a date field?

    Hi all,
    I need a field that will calculate the number of days elapsed whatever date is entered into the date field, and update that number of days based on the calendar/computer calendar date.  Does that make sense?
    https://www.dropbox.com/s/arkmnsxjkl4r156/AFBS_FacilitySpecialCareList02.pdf
    I set up the form so that my boss can add or subtract clients from the list.  Each client needs to have its own "Days since added to the list" number. Sorta like a little aging report.
    Is this possible?
    Many thanks,
    Laura

    Wow, I'm so stumped.  I tried to copy a bit of formcalc into the exit event for my current date field to try to make this happen, but I can't get it to work.
    My  attempt at scripting is embarrassing, but here it is:
    form1.sf1.CCSub.CCGroup.#subform[0].DateField2::exit - (FormCalc, client)
    form1.sf1.CCSub.CCGroup.#subform[0].NumericField2.rawValue = Date2Num(DateField1, "MM-DD-YY") - Date2Num(DateField2, "MM-DD-YY")
    and here's the file:
    https://www.dropbox.com/s/arkmnsxjkl4r156/AFBS_FacilitySpecialCareList02.pdf
    Can anyone help me get this right?
    Sign me: One Lost Designer
    Thanks!

  • How to set date +120 daye to one date field

    Hi,
    I have 2 fields one is Close date(Item style is Message Layout) and Quote Valid Until(Item Style is Date Field).After opening the page Close date will come automatically. Now My requirement is need to put Close date+120 days to Quote Valid unti field. Pls let me how to do this one and pls provide Sample code....
    Thanks in advance,
    Hanimi....

    Hanimi,
    Use Below Code
    //Convert the fetched date to calendar date and use the below method.
    import java.util.Calendar;
    public class CalendarAddExample {
        public static void main(String[] args) {
            Calendar cal = Calendar.getInstance();
            System.out.println("Today : " + cal.getTime());
            // Subtract 30 days from the calendar
            cal.add(Calendar.DATE, -30);
            System.out.println("30 days ago: " + cal.getTime());
    }Regards,
    Gyan

  • Adding days to the date field

    Hi,
    I have a scenario as below.
    I have to add no. of days to the exixsting date field in the program. The statement is like this.
               <b>DATE1 = DATE + XDAYS.</b>
    Where <b>DATE</b> is in <b>DDMMYYYY</b> format. and XDAYS holds the number of days which will be retrieved from the standard table. And DATE1 should hold the result date.
    <b>eg:</b> Let <b>DATE</b> = <b>30.08.2007</b>
               <b>XDAYS</b> = <b>15</b>
    DATE1 = DATE + XDAYS.   =>   <b>DATE1 = 30.08.2007 + 15</b>.
    <b>DATE1 = 14.09.2007</b>
    Is there any easiest way to do this. or is there any function mdule  to do this operation.
    I hope you understood the question. Please let me know if I need to be more clear.
    Thanks in advance.
    -Pradeep.

    Hi,
    The date will be in internal format of 8 digits... Like 20070830..
    Directly add the number of days.. system will automatcally calculate
    w_new = w_old + 15 (20070830 + 15)
    w_new becomes 20070914
    and when you will write this : WRITE : w_new. It will show 14.09.2007 or depending on your settings for the date format. No need to call any fm for this..
    Thanks and Best Regards,
    Vikas Bittera.
    **Reward if useful**

  • Calculate Days between same date field in multiple records, looping for each record

    Be patient as I am a newbie to Sql Server (using 2008 R2) and SSIS.  I have looked at multiple solutions in this and many other forums before submitting the question.
    I am looking at records to identify the number of days between two dates.  We review drug information.  A member uses drug A (Code identifies this called GPI) and has refills throughout time.  The goal is to calculate the days between Refill
    1 and refill 2, then refill 2 to refill 3, etc.  When that member record set is complete, we move to the next member record set.
    The basic data would be as follows.  Each record shown below would be a separate record in a single table :
    Member
    Drug Code
          DateService
             Days Between
    1
    A
    3/1/2012
    0
    1
    A
    3/27/2012
    27
    1
    A
    4/21/2012
    26
    1
    A
    6/15/2012
    56
    1
    F
    2/25/2012
    0
    1
    F
    3/20/2012
    25
    1
    F
    4/17/2012
    29
    1
    F
    8/1/2012
    107
    5
    B
    2/15/2012
    0
    5
    B
    3/10/2012
    25
    5
    B
    4/10/2012
    32
    5
    B
    6/28/2012
    80
    5
    B
    7/10/2012
    13
    5
    B
    8/20/2012
    42
    The days between is the value I am looking to calculate.  The First record for the grouping of Member and Drug Code will be zero ( 0 ) as there is no preceding date to calculate against.  The process would then loop through the records at the grouping
    (Member and Drug Code) until those records are calculated.  It would then move on to the next group of Member/Drug records.
    Any assistance would be greatly appreciated.  Any clarification I can provide, I would be more than happpy too.  Thank you in advance!

    TSQL- Finding the difference in days of multiple records in SQL ServerWITH OrderDates AS (
    SELECT
    ROW_NUMBER() OVER (ORDER BY OrderDate DESC) AS RowNumber,
    OrderDate
    FROM OrdersTable
    WHERE SKU = 'AA0000'
    SELECT
    AVG(DATEDIFF(DD, O2.OrderDate, O1.OrderDate)) AS AverageFrequency
    FROM OrderDates O1
    LEFT JOIN OrderDates O2
    ON O2.RowNumber = O1.RowNumber + 1
    Fabio Bilicki

  • How to calculate number of days from a date field

    Dear BW Experts.
    I have a field 'Create Date' in the BEx query. Now we need to create a variable which should give the number of days from the date of running the query (sy-datum) to the Create Date.
    This will help the users to get records which are say, 30 days old (Sy-datum - create date = 30) or 10 days old etc.
    Could you suggest as to how to create this variable.
    Thanks,
    Sai

    Hi,
    Step 1: Create variable on "Create Date" with User entry processing type
    Step 2: Create a restricted KF for Sales & restrict it on "Create Date" to get "Sales on day"
    Step 3: Manipulate  the values of "Create Date" on which you could restrict  "Sales" again and again to get other values
    Step 4: Create one variable (ZPUTMNTH) for u201CMonth to Dateu201D with processing by u201CCustomer Exitu201D. This variable was created  on u201CDateu201D characteristics.
    Step 5 : Goto C-mod t-code and use EXIT_SAPLRRS0_001
    to calculate "month to date" user input is "Calday" Key Date
    WHEN 'ZPUTMNTH'.
    IF I_STEP = 2. "after the popup
    LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
    WHERE VNAM = 'ZPDATE'.
    CLEAR L_S_RANGE.
    L_S_RANGE-LOW = LOC_VAR_RANGE-LOW(6). "low value, e.g.YYYYMM (200606) part of key date (20060625)
    L_S_RANGE-LOW+6(2) = '01'. u201C low value e..g. YYYYMM01 (20060601)
    L_S_RANGE-HIGH = LOC_VAR_RANGE-LOW. "high value = input
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'BT'.
    APPEND L_S_RANGE TO E_T_RANGE.
    EXIT.
    ENDLOOP.
    ENDIF.
    Assign if helps.....
    Regards,
    Suman

  • Using variables to add and subtract a number in a text field?

    The adding bit works fine:
    // get this pconn count
    var this_p_conn:Number = Object(this).parent.p_conn;
    // get current pconn total
    var c_this_p_conn:Number = Object(root).part_count.p_conn_count.text    
    // add this pconn count to total pconn
    var v_this_p_conn:Number = Number(this_p_conn+c_this_p_conn);
    // Update total pconn with new value
    Object(root).part_count.p_conn_count.text = String(v_this_p_conn)
    Removing a value from the total is another story, this looks like it should work but it does not:
    // get this pconn count
    var count_p_conn:Number = Object(this).parent.p_conn;
    // get current pconn total
    var total_p_conn:Number = Object(root).part_count.p_conn_count.text;
    // subtract this pconn count from total pconn
    var new_p_conn:Number = Number(total_p_conn-count_p_conn);
    // Update total pconn with new value
    Object(root).part_count.p_conn_count.text = String(new_p_conn);
    Any ideas or suggestions? My eyes are a bit blurry from looking at code, maybe I missed something obvious. Thanks in advance!

    Never mind, I got it worked out now.
    I had the subtraction code firing AFTER my remove self code, so the player never got to fire the subtract code:
    var b:MovieClip = Object(this).parent;
    Object(this).parent.parent.removeChild(b);
    I placed the subtract code before the above code and now it works fine... I think I need powernap...
    The lesson here is that apparently code fires from the top to the bottom, mind the order of how your code is stacked.
    Sorry for the fuss! Carry on.

Maybe you are looking for