Menetapkan label kolom ini, seperti 'Ulang Tahun' atau 'Hari Peringatan'.
Dokumentasi mendetail
getLabel()
Mendapatkan label untuk kolom ini. Ini dapat berupa Kolom, ExtendedField, atau String.
// Logs the label for all the address fields associated with contact// 'John Doe'. This method can be similarly called for any field that has// a label.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();for(leti=0;i < addressFields.length;i++){Logger.log(addressFields[i].getLabel());}
Pulang pergi
Object — label untuk kolom ini
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
https://www.google.com/m8/feeds
setLabel(label)
Menetapkan label kolom ini.
// Sets the label to 'Apartment' for the first address field associated// with contact 'John Doe'. This method can be similarly called for any// field that has a label.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();addressFields[0].setLabel('Apartment');
Parameter
Nama
Jenis
Deskripsi
label
String
label baru untuk kolom ini
Pulang pergi
DateField — kolom ini, berguna untuk membuat rantai
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
https://www.google.com/m8/feeds
Metode yang tidak digunakan lagi
deleteDateField()
Tidak digunakan lagi. Fungsi ini tidak digunakan lagi dan tidak boleh digunakan dalam skrip baru.
Menghapus tanggal ini.
// Deletes all the dates that are set for contact 'John Doe'constcontacts=ContactsApp.getContactsByName('John Doe');constdates=contacts[0].getDates();for(leti=0;i < dates.length;i++){dates[i].deleteDateField();}
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
https://www.google.com/m8/feeds
getDay()
Tidak digunakan lagi. Fungsi ini tidak digunakan lagi dan tidak boleh digunakan dalam skrip baru.
Mendapatkan hari dalam sebulan untuk tanggal ini.
Catatan: Untuk objek Date JavaScript standar, metode getDay() akan menampilkan hari dalam seminggu.
// Logs the day of the birthday for contact 'John Doe'constcontacts=ContactsApp.getContactsByName('John Doe');constbirthday=contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];Logger.log(birthday.getDay());
Pulang pergi
Integer — tanggal
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
https://www.google.com/m8/feeds
getMonth()
Tidak digunakan lagi. Fungsi ini tidak digunakan lagi dan tidak boleh digunakan dalam skrip baru.
Mendapatkan bulan untuk tanggal ini.
// Logs the month of the birthday for contact 'John Doe'constcontacts=ContactsApp.getContactsByName('John Doe');constbirthday=contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];Logger.log(birthday.getMonth());
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
https://www.google.com/m8/feeds
getYear()
Tidak digunakan lagi. Fungsi ini tidak digunakan lagi dan tidak boleh digunakan dalam skrip baru.
Mendapatkan tahun untuk tanggal ini.
// Logs the year of the birthday for contact 'John Doe'constcontacts=ContactsApp.getContactsByName('John Doe');constbirthday=contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];Logger.log(birthday.getYear());
Pulang pergi
Integer — tahun
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
https://www.google.com/m8/feeds
setDate(month, day)
Tidak digunakan lagi. Fungsi ini tidak digunakan lagi dan tidak boleh digunakan dalam skrip baru.
Menetapkan tanggal ke hari ini, tanpa tahun.
Metode ini hanya berlaku untuk kolom tanggal yang tidak memerlukan tahun, seperti hari ulang tahun.
// Sets the birthday for contact 'John Doe' to April 1constcontacts=ContactsApp.getContactsByName('John Doe');constbirthday=contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];birthday.setDate(ContactsApp.Month.APRIL,1);
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
https://www.google.com/m8/feeds
setDate(month, day, year)
Tidak digunakan lagi. Fungsi ini tidak digunakan lagi dan tidak boleh digunakan dalam skrip baru.
Menetapkan tanggal ke hari ini.
// Sets the birthday for contact 'John Doe' to April 1, 1980constcontacts=ContactsApp.getContactsByName('John Doe');constbirthday=contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];birthday.setDate(ContactsApp.Month.APRIL,1,1980);
DateField — tanggal ini, berguna untuk membuat rantai
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
https://www.google.com/m8/feeds
setLabel(label)
Tidak digunakan lagi. Fungsi ini tidak digunakan lagi dan tidak boleh digunakan dalam skrip baru.
Menetapkan label kolom ini, seperti 'Ulang Tahun' atau 'Hari Peringatan'.
// Retrieves the first date that's set for contact 'John Doe' and re-labels// it as an anniversaryconstcontacts=ContactsApp.getContactsByName('John Doe');constfirstDate=contacts[0].getDates()[0];firstDate.setLabel(ContactsApp.Field.ANNIVERSARY);
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-26 UTC."],[[["\u003cp\u003e\u003cstrong\u003eDeprecated:\u003c/strong\u003e The \u003ccode\u003eDateField\u003c/code\u003e class is deprecated; use the People API advanced service instead.\u003c/p\u003e\n"],["\u003cp\u003eRepresents a date field within a Contact, specifically for the Contacts service.\u003c/p\u003e\n"],["\u003cp\u003eOffers limited functionality with \u003ccode\u003egetLabel()\u003c/code\u003e and \u003ccode\u003esetLabel()\u003c/code\u003e methods for managing date field labels.\u003c/p\u003e\n"],["\u003cp\u003ePreviously provided methods for manipulating date values are now deprecated, including \u003ccode\u003egetDay()\u003c/code\u003e, \u003ccode\u003egetMonth()\u003c/code\u003e, \u003ccode\u003egetYear()\u003c/code\u003e, and \u003ccode\u003esetDate()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eFor general date manipulation in Apps Script, use JavaScript's standard \u003ccode\u003eDate\u003c/code\u003e object.\u003c/p\u003e\n"]]],[],null,["DateField\n\n\n**Deprecated.** Instead, use the [People API advanced\nservice](/apps-script/advanced/people)\n\nA date field in a Contact.\n\nThis class is only used by the Contacts service, and dates used elsewhere in App Script use\nJavaScript's standard [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object. \n\nMethods\n\n| Method | Return type | Brief description |\n|--------------------------------------|----------------|--------------------------------|\n| [getLabel()](#getLabel()) | `Object` | Gets the label for this field. |\n| [setLabel(label)](#setLabel(String)) | [DateField](#) | Sets the label of this field. |\n\nDeprecated methods\n\n| Method | Return type | Brief description |\n|--------------------------------------------------------------|-----------------------------|--------------------------------------------------------------------|\n| [deleteDateField()](#deleteDateField()) | `void` | Deletes this date. |\n| [getDay()](#getDay()) | `Integer` | Gets the day of the month for this date. |\n| [getMonth()](#getMonth()) | [Month](../base/month.html) | Gets the month for this date. |\n| [getYear()](#getYear()) | `Integer` | Gets the year for this date. |\n| [setDate(month, day)](#setDate(Month,Integer)) | [DateField](#) | Sets the date to this day, without a year. |\n| [setDate(month, day, year)](#setDate(Month,Integer,Integer)) | [DateField](#) | Sets the date to this day. |\n| [setLabel(label)](#setLabel(Field)) | [DateField](#) | Sets the label of this field, such as 'Birthday' or 'Anniversary'. |\n\nDetailed documentation \n\n`get``Label()` \nGets the label for this field. This may be a Field, ExtendedField, or a String.\n\n```javascript\n// Logs the label for all the address fields associated with contact\n// 'John Doe'. This method can be similarly called for any field that has\n// a label.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst addressFields = contacts[0].getAddresses();\nfor (let i = 0; i \u003c addressFields.length; i++) {\n Logger.log(addressFields[i].getLabel());\n}\n```\n\nReturn\n\n\n`Object` --- the label for this field\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`set``Label(label)` \nSets the label of this field.\n\n```javascript\n// Sets the label to 'Apartment' for the first address field associated\n// with contact 'John Doe'. This method can be similarly called for any\n// field that has a label.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst addressFields = contacts[0].getAddresses();\naddressFields[0].setLabel('Apartment');\n```\n\nParameters\n\n| Name | Type | Description |\n|---------|----------|------------------------------|\n| `label` | `String` | the new label for this field |\n\nReturn\n\n\n[DateField](#) --- this field, useful for chaining\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\nDeprecated methods \n\n`delete``Date``Field()` \n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nDeletes this date.\n\n```javascript\n// Deletes all the dates that are set for contact 'John Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst dates = contacts[0].getDates();\nfor (let i = 0; i \u003c dates.length; i++) {\n dates[i].deleteDateField();\n}\n```\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`get``Day()` \n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nGets the day of the month for this date.\n\nNote: For standard JavaScript Date objects the [`get``Day()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay) method returns the day of the week instead.\n\n```javascript\n// Logs the day of the birthday for contact 'John Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];\nLogger.log(birthday.getDay());\n```\n\nReturn\n\n\n`Integer` --- the day of the month\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`get``Month()` \n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nGets the month for this date.\n\n```javascript\n// Logs the month of the birthday for contact 'John Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];\nLogger.log(birthday.getMonth());\n```\n\nReturn\n\n\n[Month](../base/month.html) --- the month\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`get``Year()` \n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nGets the year for this date.\n\n```javascript\n// Logs the year of the birthday for contact 'John Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];\nLogger.log(birthday.getYear());\n```\n\nReturn\n\n\n`Integer` --- the year\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`set``Date(month, day)` \n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nSets the date to this day, without a year.\n\nThis method only applies to date fields that don't require a year, such as birthdays.\n\n```javascript\n// Sets the birthday for contact 'John Doe' to April 1\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];\nbirthday.setDate(ContactsApp.Month.APRIL, 1);\n```\n\nParameters\n\n| Name | Type | Description |\n|---------|-----------------------------|-------------|\n| `month` | [Month](../base/month.html) | the month |\n| `day` | `Integer` | the day |\n\nReturn\n\n\n[DateField](#) --- this date, useful for chaining\n\nThrows\n\n\n[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if this date field requires a year\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`set``Date(month, day, year)` \n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nSets the date to this day.\n\n```javascript\n// Sets the birthday for contact 'John Doe' to April 1, 1980\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];\nbirthday.setDate(ContactsApp.Month.APRIL, 1, 1980);\n```\n\nParameters\n\n| Name | Type | Description |\n|---------|-----------------------------|-------------|\n| `month` | [Month](../base/month.html) | the month |\n| `day` | `Integer` | the day |\n| `year` | `Integer` | the year |\n\nReturn\n\n\n[DateField](#) --- this date, useful for chaining\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`set``Label(label)` \n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nSets the label of this field, such as 'Birthday' or 'Anniversary'.\n\n```javascript\n// Retrieves the first date that's set for contact 'John Doe' and re-labels\n// it as an anniversary\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst firstDate = contacts[0].getDates()[0];\nfirstDate.setLabel(ContactsApp.Field.ANNIVERSARY);\n```\n\nParameters\n\n| Name | Type | Description |\n|---------|------------------------------------------------|------------------------|\n| `label` | [Field](/apps-script/reference/contacts/field) | the new standard label |\n\nReturn\n\n\n[DateField](#) --- this field, useful for chaining\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`"]]