Digital Farmer
Digital Farmer

Reputation: 2107

Cell date via script

function archivr() {
  var ss = SpreadsheetApp.getActive();
  var sh = ss.getSheetByName('Página1');
  sh.getRange('A2').setValue(Utilities.formatDate(new Date(), "GMT-3", "YYYY-MM-DD"));
}

I'm trying to use this script format to put today's date in my spreadsheet, but when I try to put it, the result is:

2020-02-52

Day 52? There is no logic to this, I don't know what's going on.

Additional, how can I also add tomorrow's date in A3?

Upvotes: 0

Views: 41

Answers (1)

TheMaster
TheMaster

Reputation: 50452

As written in the official documentation, D is Day in year. Use dd instead.

Upvotes: 1

Related Questions