Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

FormCalc for dates

Avatar

Former Community Member
I would like my form to precalculate dates based upon an original date entry. for example:

Initital entry: 2/28/06

Following entry: 3/28/06 (calculated, read-only)(based on initial entry

Following entry: 4/28/06 (calculated, read-only)(based on initial entry



is this possible? it cannot calculate 30-31 days since all months vary, I want it to calculate consecutive dates (same day each month)



Please help!
1 Reply

Avatar

Former Community Member
Does it have to be in FormCalc. With FormCalc it would be easy to do if you were looking for something like "what's the date 30 days in the future" but a lot harder for what you want.



You could do this easily in JavaScript using the Date object. It would be something like this:



Date d = new Date(initialDate);



...



//increment month

d.setMonth(d.getMonth() + 1);



You'll have to put some logic to make sure it's not December and if it is then set the next month back to 0.



There are many tutorials online that explain how to use a JavaScript Date.



Chris

Adobe Enterprise Developer Support