PascalL
PascalL

Reputation: 175

getDate() does not work in google AppScript

var now = new Date();
var dayofmonth = now.getDay();
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.getRange('A7').setValue(dayofmonth);

dayofmonth returns: 31.12.1899 now.getDate() returns: 25.01.1900

Why does this not work?

i need only the day of the month like 29

Upvotes: 1

Views: 7679

Answers (1)

jbra95
jbra95

Reputation: 909

The getDay function returns a number, from 0 to 6, representing the day of the week.

If it's returning another thing, try to delete the row, because the format of the cell could be modifying the value.

If you want the day of the month, then use:

now.getDate()

enter image description here enter image description here

Upvotes: 3

Related Questions