0

Can you help me out in calling a date from spreadsheet?

I used getRange("range where date is present in my spreadsheet"), if I use this function, then in logger.log it is showing me previous date.
Ex: if the date is 1st Jan 2020, when I use this function for calling, it is showing me Dec 31st 2019.

Here is the code that I used

function myfunction(){

var ss = SpreadsheetApp.getActiveSpreadsheet();

var cs = ss.getSheetByName("Sheet1");

var d1 = cs.getRange(2,3).getValue();

}

Now if I see in logger.log(d1); it is showing me previous date instead of, date that is present in the range given.

Rubén
  • 34,714
  • 9
  • 70
  • 166
  • Welcome to [so]. Add what is shown in the logger as well the timezone of your spreadsheet and the timezone of your project. – Rubén Jun 17 '20 at 02:21
  • 1
    Looks very much like 1st Jan 2020 is local and Dec 31st 2019 is the UTC equivalent (given that you haven't included the time part). Is your timezone east of Greenwich (I'll guess +5:30)? – RobG Jun 17 '20 at 05:12
  • Hi Ruben & RobG, thanks for your response, I have figured my time zone, and sorted my problem. Will reach out to forum, for any further quires. – Sri Vathsav Jun 18 '20 at 03:19

1 Answers1

1

As other have suggested in the comments.

The most plausible explanation for the difference in the date is the timezone of your sheet.

Reference

Raserhin
  • 2,516
  • 1
  • 10
  • 14