Google Apps Script: Retrieve Date from Spreadsheet and write to Contacts -
using google apps script, i'm trying take date written in spreadsheet , add date field contact. specifically, cannot seem convert month of javascript date read spreadsheet month enum contact.adddate method can use.
var months = contactsapp.month.values; var birthdate = new date( spreadsheet_date ); var month = months[ birthdate.getmonth() ]; contact.adddate(contactsapp.field.birthday, month, birthdate.getdate(), birthdate.getfullyear() );
there lots of ways approach, see switch easiest, there's no one-liner though, there's no month name built javascript:
var month = birthdate.getmonth(); switch(month){ case 0: month = contactsapp.month.january; break; case 1: month = contactsapp.month.february; break; [...] case 11: month = contactsapp.month.december break; }
Comments
Post a Comment