Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

339
Views
Apps Script and Google Sheets, Creating calendar event

When I try to run the following code when the start and end dates are the same (to create a calendar event from data submitted through Google Forms), I get this error: Exception: Event start date must be before event end date.

else if (approval == Approval.Approved) {
// If approved, create a calendar event.
CalendarApp.getCalendarById(email)
    .createAllDayEvent(
        'OOO - Out Of Office',
        startDate,
        endDate,
        {
          description: message,
          guests: additionalEmail,
          sendInvites: true,
        });

Since employees can request a full or partial day off, I would like the script to be able to run even if the values are the same. How would I make this happen?

Also, for background, I have very limited coding experience (next to nothing except for basic R), so if it's possible, please dumb it down for me. Thank you so much for your time and help!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As per documentation (https://developers.google.com/apps-script/reference/calendar/calendar), you can:

Create a one-day event like so: createAllDayEvent(title, date)

.createAllDayEvent(
        'OOO - Out Of Office',
        startDate,
        {
          description: message,
          guests: additionalEmail,
          sendInvites: true,
        });

Create multiple-day events like so: createAllDayEvent(title, startDate, endDate)

.createAllDayEvent(
        'OOO - Out Of Office',
        startDate,
        endDate,
        {
          description: message,
          guests: additionalEmail,
          sendInvites: true,
        });

Create partial-day events like so: createEvent(title, startTime, endTime, options)

.createEvent(
        'OOO - Out Of Office',
        startTime,
        endTime,
        {
          description: message,
          guests: additionalEmail,
          sendInvites: true,
        });

With regard to times in Apps Script, here's a snippet of syntax:

new Date('July 20, 1969 20:00:00 UTC');

And docs link: https://developers.google.com/google-ads/scripts/docs/features/dates

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!