1

I am using an onEdit trigger to trigger a Google Apps Script. Essentially, I am using the results of a Form to populate a calendar event. Once I've created the calendar event, I want to be able to keep it in sync with the form entry. So if someone edits the form data, I want to edit the calendar event. Unfortunately, since there is no getEventById storing the eventId is not enough.

I was thinking I might be able to use the event['oldValue'] which stores the event time to figure out when the event used to be (in case it changes) to get a list of events at that time which will allow me to iterate through a small number of events to find the calendar event.

Unfortunately, the date object comes out as a weird floating point number that I can't parse. e.g: 1/19/2016 20:00:00 comes out as 42388.791666666664 which I really don't understand.

I did have another thought, should I just use a regular HTTP get call to get the event I want? I'm not exactly sure how to do that from within a Google Apps Script

JonathanC
  • 967
  • 11
  • 30
  • What is the value of the date in the spreadsheet? What is the format of the column? What is the line of code that gets the value? – Alan Wells Jan 24 '16 at 20:50

1 Answers1

3

Maybe late, but you can see the answer here

var x = 42521.015713761575;

// seconds in day = 24 * 60 * 60 = 86400
var date = new Date(1899, 11, 30, 0, 0, x * 86400);
Community
  • 1
  • 1
maXp
  • 1,428
  • 1
  • 15
  • 23