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.

HELP!! Can't calculate date fields

Avatar

Level 3

I have a cript that calculates between 2 date fields.

They have a date format of: DDMMYYYY

In an other form with a different date format it works, but here it doesn't

What am i doeing wrong?

var dateOfPensioen = formulier1.Formulier.Vraag2.RetirementDate.Date2.rawValue;

var dateOfChange = formulier1.Formulier.Vraag1.Date.Antwoord4.rawValue

var Horizon = 0;

if (dateOfPensioen != "" && dateOfChange != "")

     {

var datePensioen = util.scand("yyyy-mm-dd hh:mm", (dateOfPensioen + " 0:00"));

var datePeil = util.scand("yyyy-mm-dd hh:mm", (dateOfChange + " 0:00"));

if (datePensioen != null && datePeil != null)

               {


// calculate horizon in months

var calcHorizon = ((datePensioen.getFullYear()-datePeil.getFullYear()) * 12 + (datePensioen.getMonth() - datePeil.getMonth()) - Math.max(0,Math.min(1,(datePeil.getDate()-datePensioen.getDate())))) / 12;

var Horizon = calcHorizon.toString();

               }

     }

I'm keep getting an error: util not defined

0 Replies