Expand my Community achievements bar.

1 & 2 Year Calendar Date Calculations

Avatar

Level 1

Hi All,

I am a total newbie to designing forms so please bear with me.

I am currently working with a lease form and i need to do the following:

I want to be a to fill in a date field with a Lease Start date: ex.. "09/01/2010"

and have a script or calculation output the corresponding 1 and 2 year Lease End Dates to separate date fields.

which in this case would be 1 year "08/31/2011" 2 year "08/31/2012".

I want it to verify that the dates are correct and account for leap years.

I would prefer if this could be done in Formcalc, as I have no experience whatsoever in using Javascript.

Thank you in advance for any help you guys can provide.

1 Reply

Avatar

Former Community Member

I just created a sample foe someone else on this same topic. In this instance using Javascript is easier than FormCalc so that is what I used. We can take the date field and separate it into its components of day, month and year. Once we have the year we can add 1 or 2 to it and then simply put the date back together again to make a date. This way we do not have to worry about leap years ar adding 365.25 days. Have a look at the code ..it is pretty straight forward. If you have questions do not hesitate to ask. The code is on the click event of the button.

Paul