Updating to NULL in DateTime Field

datetime, null, php, sql

Solution

Remove the apostrophes around the null value:

$updatedateapprovedsql = "UPDATE [Problem Data Table] SET [Corrective action approved] = null WHERE [8D Number]='$pionumber'";

Problem

I am using PHP and SQL through an ODBC connection to update a DateTime field that had a date in it to NULL. The field can be NULL I know that. I have tried setting it NULL with and without quotes but still no success. I know the SQL works because if I input a date instead of NULL it works. Any help would be amazing. ``` $dateapproved = "NULL"; $updatedateapprovedsql = "UPDATE [Problem Data Table] SET [Corrective action approved]='$dateapproved' WHERE [8D Number]='$pionumber'"; $updatedateapprovedresult=odbc_exec($connection,$updatedateapprovedsql); ```

Original source