Supported unit specifiers for DATETIME_DIFF
  • 07 Jul 2022
  • 1 Minute to read
  • Dark
    Light

Supported unit specifiers for DATETIME_DIFF

  • Dark
    Light

The DATETIME_DIFF() function will allow you to calculate the difference between two different datetimes in specified units. Each specifier has a corresponding abbreviation which will work the same as the longform version of the specifier, e.g. DATETIME_DIFF(Date, Date2, 'y') will have the same output as DATETIME_DIFF(Date, Date2, 'years').

your title goes here

If no unit is specified, or the specifier is not recognized by the function, then the output will default to seconds. If the unit specified is not recognized, the output will default to milliseconds.

The following is a table of the supported time units for DATETIME_DIFF(), along with the equivalent abbreviated specifiers for each:

Unit specifier
Abbreviation
 'milliseconds'  'ms' 
 'seconds'  's' 
 'minutes'  'm' 
 'hours'  'h' 
 'days'  'd' 
 'weeks'  'w' 
 'months'  'M' 
 'quarters'  'Q' 
 'years'  'y' 

Note that the above unit specifiers will also work with the majority of other datetime functions such as DATEADD().

If you're looking to use workdays as a unit for DATETIME_DIFF(), you may want to use the formula WORKDAY_DIFF() instead.

TIP

When attempting to use DATETIME_DIFF() with static dates or dates that are formatted as strings you will want to nest the DATETIME_PARSE() function within your formula in order to turn the string into a readable date on Airtable's backend. Example: DATETIME_DIFF(DATETIME_PARSE('12/31/2021', "M/D/YYYY"), {Start Date},'d')

Was this article helpful?