0

So I am using google sheets with google scripts to sort some data and then put it into a new sheet. I have been using the .valueOf() method to grab the data from an array that grabbed all the data using sheet.getDataRange().getValues(); and has worked perfectly with grabbing everything in all the other places besides my column containing the dates in the "dd/mm/yyyy" order. It grabs it but then puts it into my new sheet in the form of some massive number (which I think could possibly be seconds or milliseconds). I don’t want a time stamp, I want to reverse whatever that time stamp thingy is.

Example: Original Date and After grabbing date and moving to new sheet

Below I have posted the code I am using. Any help or advice is greatly appreciated!

Code: https://pastebin.com/snn3jDcH

line where I grab the date:


for(var i = 1; i < data.length; i++) {
    test = data[i][2].valueOf().substring(0,5);
    if(test === "ES014")
    {
       DateStore[count] = data[i][0].valueOf();
       NameStore[count] = data[i][1].valueOf();
       NumStore[count] = data[i][2].valueOf();
       QuantityStore[count] = data[i][3].valueOf();
       count++;
    }

Sorry about the formatting, but it wouldn't let me post unless I did it this way. No clue why but sorry! Thank you for this long read!

Riyafa Abdul Hameed
  • 7,417
  • 6
  • 40
  • 55

1 Answers1

0

Instead of sheet.getDataRange().getValues(); and then doing valueOf()

Simply only do sheet.getDataRange().getDisplayValues(); and I think valueOf() is not necessary.

For further informations check this out

https://developers.google.com/apps-script/reference/spreadsheet/range#getdisplayvalues

Umair Mohammad
  • 4,489
  • 2
  • 20
  • 34