Kamil Yakoubi

Kamil Yakoubi

  • NA
  • 1
  • 559

SUM time and disply it

May 10 2016 3:59 PM
hi
i have mysql table (arret) , i want to sum (duree) it's time column (HH:MM:SS)
i tried this 
  1. string query = "SELECT  SEC_TO_TIME( SUM( TIME_TO_SEC( `duree` ) ) )   FROM arret ;";  
  2.             cmd = new MySql.Data.MySqlClient.MySqlCommand(query, conn);  
  3.          
  4.             try  
  5.             {  
  6.                 conn.Open();  
  7.                  
  8.                 int  s = cmd.ExecuteNonQuery();  
  9.                 label1.Text = s.ToString();  
  10.   
  11.                 
  12.             }  
  13.   
  14.             catch (Exception ex)  
  15.             {  
  16.                 MessageBox.Show(this, ex.Message);  
  17.   
  18.             }  
  19.             conn.Close();  
 it's giving me (-1)
my table contains 00:09:00
00:12:32
 

Answers (1)