Jump to content


This topic is now archived and is closed to further replies.


Calc end date of event

Recommended Posts

Hi All

I can't move now. I've been trying to calculate the end date(due date in 3months time) for a specific event by getting the startdate from the database then calculate the end date.I think I got it, but now the problem is that, I want to write it to my dababase using the update statements. It doesn't want to write now. What can I do? What have a done wrong here???

ps help me good people

here is my small code:

$edatetime = $_POST['edatetime'];
// prepare query
$sql="SELECT sdatetime FROM eventscalendar";
//execute sql statements
$rsdate = mysql_query($sql, $connimgp) or die(mysql_error());
//retrieve one row of records
$sdatetime = mysql_fetch_array($rsdate);
//determine the number of records in recordset
$num_rows = mysql_num_rows($rsdate);
//echo $sdatetime['sdatetime'];
$sdatetime= $sdatetime['sdatetime'];
echo "<br>";
$edatetime = time() + (61 * 24 * 60 * 60);
// 7 days; 24 hours; 60 mins; 60secs
echo 'Date Posted: '. $sdatetime ."<br><br>";
echo '3 month due date: '. date('Y-m-d', $edatetime) ."\n";

//Insert into the database
$insertSQL = "UPDATE eventscalendar SET edatetime = '".$edatetime."' WHERE eventid=49";
//Execute the insert statement
$execute = mysql_query($insertSQL, $connimgp) or die(mysql_error());
//Redirect to policy.php
if ($execute) {


What could be the problem here? Please help me....I've been trying to this for 2days now. Can somebody provide me with his/her own source code to help me.

thank you

Share this post

Link to post
Share on other sites
because, in the update query, you always update eventid49...

by the way, there's an easier way to do this thing:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']UPDATE[/span] eventscalendar SET edatetime[color=orange]=[/color](sdatetime [color=orange]+[/color] INTERVAL 3 MONTH) [color=green]WHERE[/color] eventid[color=orange]=[/color]49 [!--sql2--][/div][!--sql3--]

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.