Home > Mobile >  "ReferenceError: DATE is not defined" in AppScript for Google Calendar
"ReferenceError: DATE is not defined" in AppScript for Google Calendar

Time:11-13

I'm trying to figure out how to add a new event to my calendar. So far all the tutorials I've followed use new Date(date) to define the dates of their events, but when I try to do the same, it gives me the error:

ReferenceError: DATE is not defined

This is my code:

function LGBT_Holidays() {
  let calendar = CalendarApp.getCalendarById("a3e1a2415c1dad9d1a8ac46ce42bc8d8a9c94ee35f77397a64854eeee8cfed61@group.calendar.google.com")
  calendar.createAllDayEvent("Transgender Awareness Week", new DATE("November 13, 2022"), new DATE("November 19, 2022"), {description:"A week to raise awareness of transgender people."})
}

Every time I Google how to add an event to Google Calendar, it gives me something similar.

CodePudding user response:

Instead of

new DATE("November 13, 2022")

use

new Date("November 13, 2022")

The above, because DATE is not the same than Date. In Google Sheets it doesn't matter if formula functions are wrote using lower case, upper case or a combination of both but Google Apps Script / JavaScript are case sensitive, this means that it's important to use upper case and lower case characters properly.

Related

  • Related