0

Hi hope someone can help me
How can i update a date field to NULL so that i have 0000-00-00 in the date field

i have the following code but it's not working i tried a lot of things but nothing wil work

if($_POST['geboortedatum'] == "")
        {
        $date = NULL;
        $updatequeryz = "UPDATE stamboom_dohmen SET geboortedatum='$date' WHERE id='$idpersoon'";   
        mysql_query($updatequeryz) or die (mysql_error()); 


        }

Thanks in advice John

2
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by johnnyd1963
0

I think the datefield by default stores NULL. If you want this then

$updatequeryz = "UPDATE stamboom_dohmen SET geboortedatum=NULL WHERE id=$idpersoon";

Without the single quotes

You can alter the field to accept a default of 0000-00-00 if you want. Then ionstead of supplying NULL you supply '0000-00-00'. Supplying NULL in the query will set the value to NULL not 0000-00-00.

0

sorry but that dosn't work it give me always the date of today
I have to tell the mysql field id set to DATE

even i tried
$updatequeryz = "UPDATE stamboom_dohmen SET geboortedatum='' WHERE id=$idpersoon";

Edited by johnnyd1963

0

Sorry i have found it i had a misstype in a pease of javascript
and that was
onclick="document.getElementById('demo1').value=' ' "
i change it in
onclick="document.getElementById('demo1').value='' "

whan i use

$updatequeryz = "UPDATE stamboom_dohmen SET geboortedatum=NULL WHERE id=$idpersoon";

it give the date 1970-01-01

and

$updatequeryz = "UPDATE stamboom_dohmen SET geboortedatum='' WHERE id=$idpersoon";

wil give 0000-00-00

thanks for your help

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.