I have an issue in updating only date in datetime field type in MYSQL.
I am taking the input from the user (dd/mm/yyyy) using PHP and changing only the date using UPDATE mysql statement. But the datetime field show only 0000-00-00 00:00:00.
Below code is only the php file which updates the table after taking the input from php which passes value using XMLHttprequest.
Pl see my code below:
<?php include 'accesscontrol.php'; ?>
<?php
$q4=$_GET["q4"];
$user = $_SESSION['user'];
$date_array = explode( "/", $q4 );
$new = sprintf( '%4d-%02d-%02d', $date_array[2], $date_array[1], $date_array[0] );
$con = mysql_connect("localhost","tst","tst!@#");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
mysql_query("UPDATE INVHDR_edit SET Invdate= concat ('$new', time(Invdate)) WHERE usr='$user'");
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con);
?>