I’ve actually tackled this exact problem before in one of my projects. Here’s what worked well for me:
You can definitely use built-in functions within custom formulas. The key is to utilize the SpreadsheetApp class in Google Apps Script. For your specific DayName function, I’d suggest something like this:
function DAYNAME(date) {
var dayNum = SpreadsheetApp.getActiveSpreadsheet().getRange(‘A1’).setValue(date).getFormula();
var result = ‘=TEXT(’ + dayNum + ‘, “dddd”)’;
return SpreadsheetApp.getActiveSpreadsheet().getRange(‘A2’).setFormula(result).getValue();
}
This approach leverages the TEXT function to format the date as a full day name. It’s efficient and reliable in my experience. Just remember to save your script, refresh your sheet, and you should be good to go.
One tip: always test your custom functions thoroughly before implementing them in important spreadsheets. It can save you a lot of headaches down the line.