honestly the best and easiest solution for me was to create a timediff field[TIME_SPENT] "datetime" and also a minutes field [MINUTES] as "int" in SQL then by running and update query
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) {
if (e.CommandName == "Stop") {
int row = int.Parse(e.CommandArgument.ToString());
string indx = GridView1.Rows[row].Cells[1].Text;
string s = null;
s = "UPDATE LOGSHEET ";
s += "SET TIME_SPENT = DATEADD(MINUTE, DATEDIFF(MINUTE,START_TIME, END_TIME), 0) ";
s += "WHERE INDX = @p0 ";
String[] pr = new String[1];
pr[0] = indx;
cQ.execSql(s, pr);
DoGridQuery();
}
if (e.CommandName == "Stop") {
int row = int.Parse(e.CommandArgument.ToString());
string indx = GridView1.Rows[row].Cells[1].Text;
string s = null;
s = "UPDATE LOGSHEET ";
s += "SET MINUTES = (DATEPART(HOUR,TIME_SPENT)*60)+(DATEPART(MINUTE,TIME_SPENT)) ";
s += "WHERE INDX = @p0 ";
String[] pr = new String[1];
pr[0] = indx;
cQ.execSql(s, pr);
DoGridQuery();
}
}
So your table will look like
LOGSHEET
========
INDX|CLIENTNAME|PROJECTNAME|NAME| DATE | START | END |TIME_SPENT|MINUTES|
1 |ME |ProjTest |aj |06/27/2012|14:10:00|13:10:00| 01:00:00 |60 |
protected string GetTotal() {
string userid = Session["id"].ToString();
string s = null;
s = "SELECT SUM(MINUTES) ";
s += "FROM LOGSHEET ";
s += "WHERE USERID = @p0 ";
String[] pr = new String[1];
pr[0] = userid;
return cQ.GenQuery(s, pr);
}
AND THEN JUST
Label5.Text = GetTotal();
But then again that's just me?!? ;)
if anyone has other ways feel free to post them I'm keen on learning new ways