cancel
Showing results for 
Search instead for 
Did you mean: 

Reg : Date Calculation

Former Member
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

chintan_virani
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Chintan,

That was really useful and I could finish my task.

Thx for ur answer.

Awarded points.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

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


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

Regards