php - Insert two date variables into startDate and endDate fields in the table -


i want insert 2 date variables startdate , enddate fields in table. first $today, next $today plus $duration.

i have piece of code used work before, not work again.

require_once('connection/config.php'); $today = date("y:m:d"); //get today's date $duration = 14; //get duration  $sql_insert = mysql_query("insert adverts (cust_id, startdate, enddate)values('".$today."', (curdate()- weekday(curdate()) +'".$duration."')");  if($sql_insert){echo 'successful';}else {echo 'failed';} 

this code worked previously. now, it's not working again. insert , returns result enddate '0000-00-00'.

i not know why returning '0000-00-00'. please me. thank all.

you can't subtract integers dates in mysql (that's oracle thing).

you need curdate() - interval weekday(curdate()) day you're trying do.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -