i have a Spreadsheet with a liste of date.
When i use this code to get the value:
function run() {
var ss = SpreadsheetApp.getActive().getSheetByName("Planning Template");
var values = ss.getRange("G3:ADS3").getValues();
var value = ss.getRange("A1").getValue();
var date = new Date (value);
for(var column in values[0]){
var test = values[0][column];
if( test == value){
var i = column;
}
}}
This is the result from getValues():
[[42370, "", 42371, "", 42372, "", 42373, "", 42740, "", 42741, "", 42742, "", 42743, "", 42378, "", 42379, "", 42380, "", 42381, "", 42382, "", 42383, "", 42384, "", 42385, "", 42386, "", 42387...
And this is the result from getValue(): Sun Jan 01 2017 00:00:00 GMT+0100 (CET)
I dont understand why Spreadsheet return a ntp time.
Edit: That is the value normally i expect that when i call getValue i get this value but i get this 42373. Its formated but the value is still a date why do i get a formated number? That is the shown value as i exoect i get 3 when i call getDisplayValue.
The methods
getValue
andgetValue
may return "Number, Boolean, Date, or String depending on the value of the cell." Specifically, you getIn your case, you should make sure that the columns you are comparing have the same kind of formatting, probably the date formatting is what you want.