I have a nuDate input field which data type is datetime, with a default value of NULL.
It saves correctly when a date value is entered; however when the date is cleared out the value is stored as 0000-00-00 00:00:00 instead of NULL.
It needs to be stored as NULL. How can I fix it?
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
datetime NULL
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: datetime NULL
Hi,
Add this in the After Save Event (PHP):
Replace:
table_name: name of your table
your_date_field: field to be updated
table_name_id: primary key of your table
Add this in the After Save Event (PHP):
Code: Select all
if ('#your_date_field#' == "") {
$sql = "UPDATE table_name SET your_date_field = NULL WHERE table_name_id = '#RECORD_ID#' ";
nuRunQuery($sql);
}
table_name: name of your table
your_date_field: field to be updated
table_name_id: primary key of your table