0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【GAS】型を判定して変換を行う

Posted at

例えば日付型をそのまま出力すると↓のような表示になってしまう

Sat Dec 30 1899 23:59:00 GMT+0900 (JST)

これを文字列型に変換するとしたら↓

var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var workingSheet = spreadsheet.getSheetByName("hogehoge");
var range = workingSheet.getRange(1, 1);
var content = range.getValue();
var objectType = Object.prototype.toString.call(content);
if (objectType == '[object Date]') {
    content = Utilities.formatDate(content, 'Asia/Tokyo','yyyy/MM/dd');
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?