Imposta l'etichetta di questo campo, ad esempio "Compleanno" o "Anniversario".
Documentazione dettagliata
getLabel()
Recupera l'etichetta di questo campo. Può essere un campo, un campo esteso o una stringa.
// 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());}
Invio
Object: l'etichetta di questo campo
Autorizzazione
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.google.com/m8/feeds
setLabel(label)
Imposta l'etichetta di questo campo.
// 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');
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.google.com/m8/feeds
Metodi ritirati
deleteDateField()
Ritiro. Questa funzione è deprecata e non deve essere utilizzata nei nuovi script.
Elimina questa data.
// 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();}
Autorizzazione
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.google.com/m8/feeds
getDay()
Ritiro. Questa funzione è deprecata e non deve essere utilizzata nei nuovi script.
Recupera il giorno del mese per questa data.
Nota: per gli oggetti Date standard di JavaScript, il metodo getDay() restituisce invece il giorno della settimana.
// 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());
Invio
Integer: il giorno del mese
Autorizzazione
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.google.com/m8/feeds
getMonth()
Ritiro. Questa funzione è deprecata e non deve essere utilizzata nei nuovi script.
Restituisce il mese di questa data.
// 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());
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.google.com/m8/feeds
getYear()
Ritiro. Questa funzione è deprecata e non deve essere utilizzata nei nuovi script.
Recupera l'anno di questa data.
// 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());
Invio
Integer: l'anno
Autorizzazione
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.google.com/m8/feeds
setDate(month, day)
Ritiro. Questa funzione è deprecata e non deve essere utilizzata nei nuovi script.
Imposta la data sul giorno corrente, senza anno.
Questo metodo si applica solo ai campi della data che non richiedono un anno, ad esempio i compleanni.
// 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);
Error: se questo campo della data richiede un anno
Autorizzazione
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.google.com/m8/feeds
setDate(month, day, year)
Ritiro. Questa funzione è deprecata e non deve essere utilizzata nei nuovi script.
Imposta la data su quella odierna.
// 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);
Gli script che utilizzano questo metodo richiedono l'autorizzazione con uno o più dei seguenti ambiti:
https://www.google.com/m8/feeds
setLabel(label)
Ritiro. Questa funzione è deprecata e non deve essere utilizzata nei nuovi script.
Imposta l'etichetta di questo campo, ad esempio "Compleanno" o "Anniversario".
// 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);
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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`"]]