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!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums 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