How can I set a timestamp in a form to null instead of an empty string?

When I submit a form with an empty time stamp field it sends the value as an empty string. I set the default field value to null. Not sure why it sends an empty string. Is there a way to make a time stamp nullable?


You could use a ternary operator wherever you connect your form input to your query. Something like:

1 Like

Thanks benbarry!

That should work. Do you know if there is a way to set the default as null. Setting it as {{ null }} results in an empty string.

Nope, I don't know any other way.

1 Like


Just want to provide some context here - null values in date components are actually intentionally recast as empty strings because of their interaction with the Date() constructor:

> new Date(null) 
Wed Dec 31 1969 16:00:00 GMT-0800 (Pacific Standard Time)
> new Date("") 
Invalid Date

@benbarry's suggestion is the best workaround we have at the moment. Let me know if there's a particular case where it doesn't work and we can investigate!

1 Like

@Kabirdas Thanks for the explanation! I'll let you know if anything specific comes up.