UDFs - ADD_TO_DATE() function

We’ve all used the ADD_TO_DATETIME() Airscript function to add any given number of the supported date/time units and returns a new dateTime obj.

What if we just want to add to a Date obj instead?

Well well well, we can build our very own UDF to take care of that, and then just call our function anywhere in Studio. Let’s get on that.


ADD_TO_DATETIME(UPDATE_DATE(NOW(), date), amount, day_month_year).date


  • date (dataType: Date)
  • amount (dataType: Number)
  • day_month_year (dataType: Text)


All UDFs have a single output, we can choose the dataType for:

  • Output dataType: Date

Your UDF should look like

Building process

Given a date obj

  "day": 18,
  "month": 2,
  "year": 2022
  1. We’ll need to do is transform it into a DateTime obj, we’ll use the UPDATE_DATE() function for that

    UPDATE_DATE( NOW(), date)
  2. Next, we’ll want to add to that DateTime obj, using the aforementioned ADD_TO_DATETIME() Airscript function

    ADD_TO_DATETIME( DateTime, 1, "month")
  3. Last, we want to obtain just the date bit of the resulting DateTime obj:

1 Like

This makes it a lot easier to add dates without having to write a complex function each time. Thanks @juanchax!

1 Like