All I need to do is take two datetime fields and set a third field to its result.
This has to be easy but I've been working on it for 2 days and cannot get the result I'm looking for.
$con = mysqli_connect(DBHOST, DBUSER, DBPASS, DBNAME) or die('Connection failed: ' . mysqli_connect_error());
$helpme=mysqli_query($con, "UPDATE chat_main SET Exact_Time = DATEDIFF(Start_TimeStamp, End_TimeStamp)");
mysqli_close($con);
Answer
The issue is that DATEDIFF returns the number of days between two dates. It appears that in the context of your implementation, the two dates are on the same day. So, you always get 0 as a result of DATEDIFF. I suggest using TIMEDIFF, which will be the difference of the two times, not the two dates.
No comments:
Post a Comment