These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Calculate Date

koenigma
Registered: Jan 23 2008
Posts: 45
Answered

I have a form with 2 calenders and a text field, with the following Names:

DateQualified
DateVerified
Validtill

I have placed the following code in calculate in Validtill selecting FormCalc Client
// If DateQualified and DateVeriified are not empty
if (HasValue(DateQualified) AND (DateVeriified)) then

// Calculate Validity period based on Verification Date
Num2Date( Date2Num(DateVeriified.formattedValue, "MMM D, YYYY") + 180)
else

// Calculat Vality period based on Qualification Date
Num2Date( Date2Num(DateQualified.formattedValue, "MMM D, YYYY") + 180)

endif

When open the form Validtill displays the date "June 29, 1900" and when I select anonther date either the DateQualified or DateVerified, nothing happens.

Any help to let me know where the problem is with this Code would be appricated, since I am at a tolal loss were to go further.

Martin

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
The script is doing exactly you have coded it to do.

If both of the date fields have a value it will calculate the text for valid using the verified date

And if there is no entry it does not do anything and fills in with an assumed date.

This script will handle the empty fields and copute the date using the verified if present and the qualified date if the verified date is not present.

// If DateQualified or DateVeriified are not empty
if (HasValue(DateQualified) or HasValue(DateVeriified)) then

// Calculate Validity period based on Verification Date
if ( HasValue(DateVerified) ) then
Num2Date( Date2Num(DateVeriified.formattedValue, "MMM D, YYYY") + 180)
else
// Calculate Validity period based on Qualification Date
Num2Date( Date2Num(DateQualified.formattedValue, "MMM D, YYYY") + 180)
endif// no values for date qualified and date verified value is null
else
null
endif

George Kaiser

koenigma
Registered: Jan 23 2008
Posts: 45
Just wanted to thank you for your assistance. Problem solved
Martin