Date Comparing

Issue 

Date Comparing
 

Solution 


1. Add a Date Comparing control to your script page

2. Set the Date Comparing control to the age you are checking i.e. 18

3. Add the following into a Calcuation control:

dateparts = [Date Comparing].split('/');
if(compDate(trim(dateparts[1] + '/' + dateparts[0] + '/' + dateparts[2]),((new Date()).getMonth()+1)+"/"+ (new Date()).getDate() +"/"+((new Date()).getFullYear() - 18)))
{
  [Age] = 'Under Age';
}
else
{
  [Age] = 'Over Age';
}

[var_age] = [Age];

4. If you need to check this before going to different pages then assign the calculation to either a Hidden field or variable

5. In a Conditional Button check the Hidden field or variable