In my Apps Script, I need to use the same format of (yesterday's) date in multiple different functions. So I decided to make my own custom makedate()
function to reliably create this date for me when I needed it. The issue, however, is that it's returning undefined
instead of my date. Here is my current function:
function makeDate(){
var myDate = new Date();
var date = (myDate.getDate()-1) + "-" + (myDate.getMonth() + 1) + "-" + myDate.getFullYear();
Logger.log(date);
return date
}
In the log file, I see that the date is being created in the format I want. However, when I then make another function to test the return value, the log file shows Made date:
with no date following it, and other uses show that the value is undefined. What am I doing wrong?