1. Knowledge Base
  2. How-To Guides
  3. Logic, Equations, & Formulas

How to Automatically Generate Expiration Dates/End Dates

Quickly learn how you can automatically generate expiration dates/end dates in Knack by utilizing a date and equation field in your data table.

Example Use Case

Imagine you're responsible for managing documents in a workplace environment where regulatory compliance is essential, such as a healthcare facility, a legal firm, or a financial institution. Ensuring that documents are regularly reviewed and updated to comply with changing regulations is crucial for maintaining legal and operational integrity.

With Knack, you can streamline the process of managing document expiration dates and ensure that your organization remains compliant. 🚀


If this is your first time creating a Knack app, you'll need to know some basics about adding tables, fields, pages, and views. You can start by learning from our Builder Basics section. 

In this article, we will work with a date/time field, a number field, and an equation field. These three field types are covered in our Field Types article. 


1.  In your data table, add a date/time field to hold the start date.

First, in the data table that you wish to implement an expiration date, add a date/time field.

Example:  expirationdates1

2.  (Optional) Add a number field to hold the number of days before expiration. 

For this example, we will want to allow users to input the number of days before the document expires. This will allow the equation field we will be creating next to generate the expiration date.



Note: If you only wish to have the expiration date be a set number of days/years out from the published date, this number field is not necessary to add. See the tip in step 3 below to learn how to configure your equation field for this setup. 

3.  Add an equation field to generate the expiration date.

To have Knack generate the expiration date of the documents, add an equation field to your data table. 

For this example, the equation field will be configured like this:


Tip: To calculate the expiration date without using a number field, you can simply add a number of days/years to your equation field editor. Depending on whether you want your expiration date to be a number of days ahead or a number of years, you will need to select the appropriate Date Type in the equation field's settings (see below image).

For example, to set the expiration date to 1 year from the published date, in the equation editor, you can simply add +1 after the date field that was added in step 1. Your equation editor will look like this instead:


4.  Test the equation field by submitting a record. 

For the last step, to ensure the expiration dates will successfully generate for your users, you can test this in the Live App or by adding a record in the Builder.

For this example, there is a form to submit a document and a grid view below to display the document's details: expirationdates5

Video Walkthrough

You can watch a detailed video on this workflow here: