Expand my Community achievements bar.

SOLVED

Date field calculation

Avatar

Level 1

I have a form that the user enters a date completed in one field and I want to have this date + 45 days calculated in another field (due date). Any ideas on the scripting for this?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Place the following script in the exit event of the complete date field. Set the language to FormCalc.

     Duedate.rawValue = Num2Date(Date2Num(complete.rawValue, "YYYY-MM-DD")+45,"YYYY-MM-DD");

Thanks

Srini

View solution in original post

11 Replies

Avatar

Level 10

Here is a sample for you..

https://acrobat.com/#d=wIoJ1TaNXLYBlEfkPdr8AA

Check the Change event of the first Date field..

Thanks

Srini

Avatar

Former Community Member

I have an example that does something similar.

Please see the attached file.

Paul

Avatar

Level 1

I like your form but I can't see your formula?

Avatar

Level 1

Thanks for your quick response - i don't have the correct version of Adobe to open your example and I don't have administrative rights to download it :-(

Avatar

Level 10

This is what I placed in the change event..

DateTimeField2.rawValue = Num2Date(Date2Num(DateTimeField1.rawValue, "YYYY-MM-DD")+45,"MM/DD/YYYY");

Thanks

Srini

Avatar

Level 1

Thank you for your response.  I'm very new to the form design so bear with me.  What

is a "change event"?

I need clarification on the formula.  Do I use the actual name of the fields (ie complete (date/time field 1) and duedate (date time field 2) or just the kind of field and the number it is on the form?

Avatar

Level 10

Select the complete field on your form and open the Script Editor by going to Window -> Script Editor..

Select Change event and place the following code..

duedate.rawValue = Num2Date(Date2Num(complete.rawValue, "YYYY-MM-DD")+45,"MM/DD/YYYY");

In my sample file, I used the names of the fields as DateField1 and DateField2.. So you need to change the names as per your form.

Script Editor Change Event1.jpg

Thanks

Srini

Avatar

Level 1

Hi,

The attachment you sent to me I cannot open.  I still cannot get this formula to work.  I am using Adobe Acrobat 8 Professional version 8.1.3.  Maybe that is why?

Avatar

Level 10

Can you send your form to LiveCycle9@gmail.com so I can add the script to it..

Thanks

Srini

Avatar

Correct answer by
Level 10

Place the following script in the exit event of the complete date field. Set the language to FormCalc.

     Duedate.rawValue = Num2Date(Date2Num(complete.rawValue, "YYYY-MM-DD")+45,"YYYY-MM-DD");

Thanks

Srini

Avatar

Level 1

It works!!  Thank you for your patience and assistance.