Date Calculations

For ease of use, Knackly evaluates dates with the following functions and determines the outcome.

Helper Methods Result Type Parameters

parse date text or number
today date

addDays date base date number of days to add
addWeeks date base date number of weeks to add
addMonths date base date number of months to add
addYears date base date number of years to add
subDays date base date number of days to subtract
subWeeks date base date number of weeks to subtract
subMonths date base date number of months to subtract
subYears date base date number of years to subtract
age number birth date

new date year, month, day

dayOf number

dayOfWeek number

daysBetween number

monthOf number

monthsBetween number

yearOf number

yearsBetween number







To help understand the date calculations, we will walk through an example. In many cases, you would want to list children, especially if they are minors. To use a formula to determine if a child is a minor, follow the steps below. You can also watch the accompanying video here:

[embed video]

Open the online workspace and navigate to the BirthDate variable. In most cases, it will be part of the party model. Verify that the BirthDate variable is a date variable. 

Select the Formulas tab and Add a new formula. Name it Age and verify that the type is a single number formula. 

In the Expression section, enter the formula. In this case, it is date.age(BirthDate). Select Save.

Open the template you are working on. To set up the condition to show a child if they are a minor, we will use an if statement. If you need more details about how to use if statements, review this guide.

We will need an expression that says if a child is younger than 18, then list any details about them here. If they are older than 18, leave this section blank:

{[if Children|any: Age < 18]}
Details
{[endif]}

Note that details is the location to enter in the information that may appear if a child is younger than 18.

Please let us know if you have any comments or suggestions on how to improve this guide.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us