Choosing the Right Equation Type: Numeric vs. Date

When creating equation fields in Knack, selecting the appropriate equation type is essential for ensuring accurate calculations. This article explains when to use numeric versus date equation types and provides practical examples for each.

What You'll Learn

This guide will help you confidently select the correct equation type for your calculation needs. You'll understand which type to use for extracting numeric values from dates, performing date arithmetic, and creating time-based calculations. By the end, you'll be able to implement equation fields that produce exactly the type of results your application requires.

Understanding Equation Types

When setting up an equation field, you must select an equation type: Numeric or Date. Your choice depends on what you want the result of the equation to be—either a number or a date.

When to Use Numeric Equations

Select the Numeric option if your final output needs to be a number. This includes:

Extracting Numeric Components from Dates

For example, extracting the year (e.g., "2024") out of a full date like "01/01/2024":

getDateYear({Date Field})

This function returns only the year portion as a number that can be used in calculations.

Calculations that Return Number Values

Such as adding two or more numeric fields together:

{Starting Inventory} + {Inventory Received} - {Inventory Shipped}

This formula calculates the current inventory level by starting with initial inventory, adding received items, and subtracting shipped items.

When to Use Date Equations

Select the Date option if your final output should be another date. This often involves:

Date Arithmetic

Adding or subtracting days, weeks, or months from a given date. For example, calculating 30 days after an order date for a due date:

{Order Date} + 30

In a date equation, this adds 30 days to the order date to determine when payment is due.

Shifting Dates in Time

Adding years to a date field to have the equation return the date in the future:

{Date} + 7

When used in a date equation, this adds 7 days to the specified date, giving you a new date value.

Quick Reference

  • Numeric Equation Type: Use if your result is a number (e.g., year of a date, difference between two dates in days).
  • Date Equation Type: Use if your result is another date (e.g., current date plus 30 days).

Tip: When working with dates in numeric equations, remember that the result will be a number—not a date. Conversely, when working with numbers in date equations, those numbers represent units of time (typically days) to add or subtract from dates.