I am trying to calculate the difference between two times (stored in database as time(7) so i can add it to a total time counter in a seperate model
I have this code
if (isset($_POST['Jobs'])) {
$model->attributes = $_POST['Jobs'];
$model->setScenario('closejob');
$model->status = 2; //set status to closed
//date time difference
$diff = $model->job_start - $model->job_end;
//need to get customer model and add
$customermodel = Customers::model()->findByPk($model->customer_ID);
$customermodel->total_time = $customermodel->total_time + $diff;
$customermodel->save();
if ($model->save())
$this->redirect(array('view', 'id' => $model->job_ID));
}
But it throws this error
CDbCommand failed to execute the SQL statement: SQLSTATE[22007]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Conversion failed when converting date and/or time from character string…
I realise this is because its converted the time to a string but does anyone know the correct way to accomplish this