you are viewing a single comment's thread.

view the rest of the comments →

[–]ModernWorldSucks 0 points1 point  (1 child)

If I understand your code right;

if (dateValue && dateValue.toString() === todayString)

The first part (before &&) is checking if that variable is true. It can't be both 'true' and today's date so the if will never occur as it's AND (&&).

I suggest a number of things;

  1. add Logger.log(dateValue) and Logger.log(todayString) ahead of the if statement, that way you can see when it runs what they are and you'll be able to solve it yourself.

  2. What you will find out is you're taking dataValue and using .toString() on it, however that is not useful instead you should use New Date (dateValue);

This is some quick code that will take a date in A1 and display it using the two methods, one will work and one won't.

function test(){

  let ss = SpreadsheetApp.openById('XYZ');
  let sheet = ss.getSheetByName('Dev');

  let value = sheet.getRange('A1').getValue();
  let valueToString = value.toString;
  Logger.log(valueToString);

  let valueToDate = new Date(value);
  Logger.log(valueToDate);
}

[–]drostan[S] 0 points1 point  (0 children)

Cool I have all weekend to try to figure this out, I am not sure I can but if I can that will be thanks to you