Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
Class DateField
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
日付フィールド
非推奨。代わりに、People API アドバンスト サービスを使用してください。
連絡先の日付フィールド。
このクラスは Contacts サービスでのみ使用されます。App Script の他の場所で使用される日付には、JavaScript の標準の
Date オブジェクトが使用されます。
詳細なドキュメント
getLabel()
このフィールドのラベルを取得します。これは、Field、ExtendedField、または 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.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
for (let i = 0; i < addressFields.length; i++) {
Logger.log(addressFields[i].getLabel());
}
戻る
Object - このフィールドのラベル
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。
-
https://www.google.com/m8/feeds
setLabel(label)
このフィールドのラベルを設定します。
// 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.
const contacts = ContactsApp.getContactsByName('John Doe');
const addressFields = contacts[0].getAddresses();
addressFields[0].setLabel('Apartment');
パラメータ
| 名前 | 型 | 説明 |
label | String | このフィールドの新しいラベル |
戻る
DateField - チェーンに便利なフィールド
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。
-
https://www.google.com/m8/feeds
サポート終了のメソッド
deleteDateField()
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
この日付を削除します。
// Deletes all the dates that are set for contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const dates = contacts[0].getDates();
for (let i = 0; i < dates.length; i++) {
dates[i].deleteDateField();
}
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。
-
https://www.google.com/m8/feeds
getDay()
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
この日付の月の曜日を取得します。
注: 標準の JavaScript Date オブジェクトの場合、
getDay() メソッドは曜日を返します。
// Logs the day of the birthday for contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];
Logger.log(birthday.getDay());
戻る
Integer - 日
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。
-
https://www.google.com/m8/feeds
getMonth()
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
この日付の月を取得します。
// Logs the month of the birthday for contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];
Logger.log(birthday.getMonth());
戻る
Month - 月
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。
-
https://www.google.com/m8/feeds
getYear()
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
この日付の年を取得します。
// Logs the year of the birthday for contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];
Logger.log(birthday.getYear());
戻る
Integer - 年
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。
-
https://www.google.com/m8/feeds
setDate(month, day)
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
日付を今日に設定します(年なし)。
この方法は、年を必要としない日付フィールド(誕生日など)にのみ適用されます。
// Sets the birthday for contact 'John Doe' to April 1
const contacts = ContactsApp.getContactsByName('John Doe');
const birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];
birthday.setDate(ContactsApp.Month.APRIL, 1);
パラメータ
| 名前 | 型 | 説明 |
month | Month | 月 |
day | Integer | 日 |
戻る
DateField - この日付(チェーンに便利)
例外
Error - この日付フィールドに年が必要かどうか
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。
-
https://www.google.com/m8/feeds
setDate(month, day, year)
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
日付を今日に設定します。
// Sets the birthday for contact 'John Doe' to April 1, 1980
const contacts = ContactsApp.getContactsByName('John Doe');
const birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];
birthday.setDate(ContactsApp.Month.APRIL, 1, 1980);
パラメータ
| 名前 | 型 | 説明 |
month | Month | 月 |
day | Integer | 日 |
year | Integer | 年 |
戻る
DateField - この日付(チェーンに便利)
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。
-
https://www.google.com/m8/feeds
setLabel(label)
非推奨。この関数は非推奨のため、新しいスクリプトでは使用しないでください。
このフィールドのラベル(「誕生日」や「記念日」など)を設定します。
// Retrieves the first date that's set for contact 'John Doe' and re-labels
// it as an anniversary
const contacts = ContactsApp.getContactsByName('John Doe');
const firstDate = contacts[0].getDates()[0];
firstDate.setLabel(ContactsApp.Field.ANNIVERSARY);
パラメータ
戻る
DateField - チェーンに便利なフィールド
承認
このメソッドを使用するスクリプトには、次のスコープの 1 つ以上による承認が必要です。
-
https://www.google.com/m8/feeds
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2026-01-15 UTC。
[null,null,["最終更新日 2026-01-15 UTC。"],[],[]]