Date Format Problem

wxdqz

New Member
I am sending the variables $daystochange and $datetostart to a php page to process.

The point is to move all of the rows in the table by the amount sent in $daystochange where the date is equal to or after $datetostart.

Right now $daystochange is just a number like 3 or -22.

The problem comes when the $daystochange exceeds the number of days in the acutal month instead of rolling over it keeps on adding to the day making a date like 2000-12-42. When this gets entered into the database it is invalid and spits out 0000-00-00.

Here is the code.

<?

// connect to the database
$conn = mysql_connect("localhost");
mysql_select_db("kstran",$conn);

$result = mysql_query("update ksline1 set date1 = date1 + '$daystochange' where date1 >= '$datetostart' ");

mysql_close();
# this closes the database connection
?>

Someone suggested that I use the number of seconds in a day to increment the change instead of just a number. I have tried this but it is not working.
Does anyone have any suggestions with a code example.

Thanks.
 
Back
Top