Blank date field updating as 12/31/1969 instead of NULL

I have date fields in my sql tables that can be blank and is set to have a default value of null. When I update the table with the date fields left blank, the value 12/31/1969 (or 1969-12-31 in sql table) is saved in the database. I’m not doing any date formatting on my input fields and the dynamic data, if present, is not formatted as well. How can I keep those fields blank if nothing is entered? Below are snap shots of my sql table and form. I have the same issue whether I run a multi-update or a single-record update.

2020-08-21_17-06-20
2020-08-21_17-27-36
2020-08-21_17-10-10

Add a condition to your insert/update action. So this way it will only update that field if there is a value.

Thanks, Brad, for the suggestion. However, I’ve never used a conditional before. For example, do I set the backorder_date contains “%” or something like that? Can you please elaborate with details since I’m new to Wappler? Thanks again for your help.

Exactly as you have it. Just click on the lightning bolt in the condition field and select the same form field as your input. That’s it.

Hi Brad,

Thanks for your help! It worked for my multi-update form but not for the single-record update form. I have the same settings for both but I can’t seem to figure out why it works with one and not the other. Any other ideas?

Brad,

Never mind. The single-record update works now. Thanks again for your help!

2 Likes

Putting the value in ‘Condition’ as mentioned by Brad above says to your Update script “if the value has changed, then update”. That works great in all cases except when you delete a value in the form field and leave it blank. In date fields it will put zeros and in your case will show the SQL start date as ‘1969-12-31’.

So, in your case, or wherever you want to update with NULL instead of ‘blank’ then use something like this {{$_POST.tl_prevdate.default(null)}}

3 Likes

Thanks for the help!.

BINGO! - this is perfect. just found it after a good hour banging my head … Thank You!