How to add a 'publish date' field in your Airtable external Duda collection

Liz Fedak • December 17, 2021New Paragraph

By Liz Fedak

Published: Dec. 17, 2021

0

Learn how to use Airtable formulas to set up a publish date for your collection items

If you're anything like me, you like to work on your content as far in advance as possible and have it set up to take care of itself. When it comes to updating your collections, you might want to release new content every Monday, or get things ready to display for an upcoming promotion. This guide covers how to use Airtable formulas + the Duda API to publish your content exactly when you want it live.


What are Airtable formulas?

One of the available field types in Airtable is a 'formula field'. You can use this type of field to reference other fields in your table and to create functions based on the content in those fields. This tutorial covers how to use some of the date-related formulas.


Setting up formulas to validate a publish date and time

Screenshot of the date type field in Airtable

To get started, make a copy of this Airtable base. In the table, you'll see some sample data prepared with two columns: a name field and a date field. Note that the date includes both a date and time option by turning on the "Include a time field" option.


The formula fields that we'll set up are also included, so you can delete them and follow along, or simply read about the configuration and look at how they're set up.

  1. In the third column, click the plus sign at create the new formula column.
  2. Name the column "Date time difference"
  3. Select a "formula" field type. You can type in the blue search box to quickly find the right field type.
  4. Add this formula into the formula field: DATETIME_DIFF(NOW(),{Date and time},'minutes')


The DATETIME_DIFF() function looks at the time difference between the current time and the date that is specified in the Date and time column. In the case of the example function, we asked for the difference in minutes. You can set that difference to be hours, days, minutes, and other options.


Now that we know the difference in time, we just have to know if the time is valid or not.


5. Add another formula column and name it "Date is valid".

6. Paste in this formula: IF({Date time difference} > 0,"true", "false")


This formula uses an IF() function. What that means is that it looks at the IF() statement to determine IF it is true or false. In this case, it's saying "Is the value in Date and time difference greater than 0?". The next two values are then used based on if the answer is true or false. You can change what these 2 words say. For example, the same function could be written as: IF({Date time difference} > 0,"Date is valid", "Date is invalid"). When the question inside of the IF() function is true, the first value is returned. When the question inside of the IF() function is false, the second value is returned. So the column will now say true or false for all of the values.


In Duda, now you just need to do 2 things. First, you need to go to the collection settings and add the new "Date is valid" column as a Plain text type field. Then, on the widgets where you have it connected, use Duda's built-in options to filter for the records that have "true" in the last column, or whatever text value you are using for the true values.


If you need the collection to be updated as soon as the value is true, you'll need to refresh the collection. For that, use Duda's Clear cache API endpoint to revalidate/refresh your collection and set it up to run each week at a designated time (or however often you need your contents to auto-update based on your publish times). Let us know if you need help from a Duda Expert to set up your API calls.

By Liz Fedak January 20, 2022
Make life easier for your clients and make their sites faster with optimized images by uploading images to Duda from their Airtable base
By Liz Fedak December 16, 2021
Today's the official release of my website widgetpro.io, and it almost didn't happen! Read the story to hear about the epic adventure I went on today to ensure I could make this happen.
By Liz Fedak December 14, 2021
Case study on my process when I built the custom widget shop on my website, Widgetpro.io
By Liz Fedak December 13, 2021
Streamline your content collection process using Content Snare and use the Duda API to make a site directly from the Content Snare form when it's complete
By Liz Fedak December 13, 2021
Learn how StoryWeb Creative used Duda's dynamic pages and custom widgets to manage weekly podcast content for the COPreneur Path Podcast
Image of 4 letter cards spelling out the word blog
By Liz Fedak December 13, 2021
Build a one-line Duda widget for extra blog functionality
By Liz Fedak December 13, 2021
Tired of the default blog widgets? So was I! ;) Read this tutorial to learn how you can add a custom author bar widget 
More Posts