Correct. All of the functions listed in the formula field reference are only usable in formulas.
To add a certain number of days to a given Date instance, you need to use the .setDate()
method on the instance. This is most often done in conjunction with the .getDate()
method to retrieve the existing date, like so:
let current_date = new Date();
let date_added = current_date.setDate(currentDate.getDate() + 7);
If the new date goes past the highest date in the month, JavaScript automatically adjusts the month appropriately. For example, if current_date
were today (Sept 28th), the .getDate()
method would return 28. Adding 7 to that would give you 35, but because there aren’t 35 days in September, JavaScript knows to increase the month and adjust the date appropriately, setting the new date to Oct 5th.
If you’re new to JavaScript, I strongly recommend keeping a language reference handy. It may not always be easy to know what you want to do if you’re trying to find the equivalent to a formula field function, so feel free to ask if you need guidance.