Skip to main content
Solved

Blanking out Date type field

  • February 14, 2022
  • 2 replies
  • 120 views

Forum|alt.badge.img

Hello,

I’m struggling with setting correctly a Date field. Basically I have a field with Date type which I set to Date.now() when something happens. If anything else happens I want to blank out the field and leave it emtpy. If I try…

myDate = null;

I get an error reading “Type ‘null’ is not assignable to type ‘number’”, and it seems the only way I can get rid of the error is by using…

myDate = 0;

Now, when I run the script and my “else” is executed I can’t seem to assign 0 to the field, and I’m getting an error reading “j: Can’t set cell values: invalid cell value for field ‘myDate’.
Cell value has invalid format: .0 must be a string, .1 must be a string, .2 must be an object

So, the question: how can I manually assign null/empty to a Date field so that no value is displayed?

Thanks in advance for your help.

Best answer by Kamille_Parks11

Wow, trying a very simple thing seemed to work:

myDate = "";

Is it possible that it is so simple as to insert a blank string? Can anybody with more experience confirm, please? I mean, my field now appears blank, but I’d rather have a second opinion.

Thanks!


Your errors say the format must be a string, and the documentation says Date fields accept strings.

Trust your own eyes, our opinions aren’t going to give your field a value if you have observed it to be blank.

2 replies

Forum|alt.badge.img
  • Author
  • Participating Frequently
  • 6 replies
  • February 14, 2022

Wow, trying a very simple thing seemed to work:

myDate = "";

Is it possible that it is so simple as to insert a blank string? Can anybody with more experience confirm, please? I mean, my field now appears blank, but I’d rather have a second opinion.

Thanks!


Kamille_Parks11
Forum|alt.badge.img+27
  • Brainy
  • 2679 replies
  • Answer
  • February 14, 2022

Wow, trying a very simple thing seemed to work:

myDate = "";

Is it possible that it is so simple as to insert a blank string? Can anybody with more experience confirm, please? I mean, my field now appears blank, but I’d rather have a second opinion.

Thanks!


Your errors say the format must be a string, and the documentation says Date fields accept strings.

Trust your own eyes, our opinions aren’t going to give your field a value if you have observed it to be blank.