Skip to Content
avatar image
Former Member

Reg : Date Calculation

hi,

I have a from date and to date fields on the adobe form.

And also I have a button on the form.

By default from date and to date is displayed.

Now My req is : whenever the user clicks the button ...the value which is displayed in from date field should be substracted by 7.

for ex : from date field has date sep 10.(by default).

when the user clicks the button ...

from date field should display sep3.(i.e. sep10 - 7 days = sep 3)

I dont know Java Script .

can anyone help?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 01, 2008 at 03:05 PM

    Arjun,

    I am not sure if your requirement is possible in JavaScript but can be achived in FormCalc and if you do below steps:-

    1. Lets say you have From Date Field named Date1. In Object palette --> Select Field Tab --> Enter / select a value for Display Pattern --> I selected "MM/DD/YYYY" as the pattern.

    2. In the click event of the button, select language as FormCalc and add following code:-

    if (Date1.rawValue ne null) then
    	Date1.formattedValue = Num2Date(Date2Num(Date1.formattedValue, "MM/DD/YYYY") - 7, "MM/DD/YYYY")
    else
    	null
    endif
    

    Note: If you select any other pattern for the Date1 field that make the changes in above code accordingly.

    Chintan

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Chintan,

      That was really useful and I could finish my task.

      Thx for ur answer.

      Awarded points.

  • avatar image
    Former Member
    Oct 02, 2008 at 09:52 AM

    Hi,

    In submit event of the button have you try this javascript code.

    data......date_to.rawValue = data......date_to.rawValue - 7 .
    

    Regards

    Add comment
    10|10000 characters needed characters exceeded