How to Display blank as 00/00/0000?

I am not a programer
Dates1
I am using Informer report writer. Trying to pull data from from Column A “lasttermdate” to a new column.
If lasttermdate has a value, I want to pull the displayed value
If lasttermdate is blank I want to display 00/00/0000

I am able to grab the dates not equal to null/blank. But can not get the value 00/00/0000 to display for the blanks.

Suggestions?

Code:
if(lasttermdate === “”) {
“00/00/0000”;
} else {
lasttermdate;
}

Hi,

Not sure what’s going on in the rest of your code, but there are a couple of things to be aware of with the above snippet.

  • You have curly quotes in the if statement. This is probably a copy/paste issue.
  • If this code is running inside a function, you’ll need to explicitly return a value. JavaScript is unlike languages such as Ruby, which will implicitly use the value of the last expression evaluated.
  • If it’s not inside a function and you’re not doing this elsewhere in the code, you’ll need to insert the value into the column using whatever method report writer puts at your disposal. On its own an expression of "00/00/0000" will do nothing.
  • When posting code in the forums, please highlight it as such (using the </> button in the editor toolbar, for example).

So either:

function insertIntoColumn (lasttermdate) {
  if(lasttermdate === "") {
    return "00/00/0000";
  } else {
    return lasttermdate;
  }
}

Or:

if(lasttermdate === "") {
  insertIntoColumn("00/00/0000");
} else {
  insertIntoColumn(lasttermdate);
}