Domanda

I have the following function defined in Google App Script:

function getFinYear(date){

  var year = parseInt(date.getYear());
  var month = parseInt(date.getMonth());
  // month is zero based converting it to civilzation today mode
  month = month + 1;
  var fin = ""
  if(month > 7){
    if(year == 2011){
      fin = "Fin 2012";
    }
    else if(year == 2012){
      fin = "Fin 2013";
    }
    else if(year == 2013){
      fin = "Fin 2014";
    }
  }
  return fin;  
}

When I call this function from Google Spreadsheet I get nothing. I have a value as a date type in a cell. The actual value in cell B2 is 12/03/2012. I call it as =getFinYear(B2)

I can't seem to figure out why nothing appears.

I checked if the value is cached etc. Please help.

È stato utile?

Soluzione

Is the type of cell B2 set as Date? If it is formatted as text, you could modify your function to include:

date = new Date(date);

Update: It looks like your spreadsheet is expecting date in dd/mm/yyyy format.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top