Page 1 of 1

datetime NULL

Posted: Thu Jun 28, 2018 2:52 pm
by marc
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?

Re: datetime NULL

Posted: Fri Jun 29, 2018 10:37 am
by toms
Hi,

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);
}
Replace:

table_name: name of your table
your_date_field: field to be updated
table_name_id: primary key of your table

Re: datetime NULL

Posted: Sun Jul 01, 2018 1:08 am
by admin
.

Re: datetime NULL

Posted: Fri Jul 06, 2018 8:24 am
by marc
toms, thanks!

Re: datetime NULL

Posted: Fri Jul 06, 2018 8:07 pm
by admin
.