C#同一张表中对字段1的值依次进行运算后将结果对应写入字段2
现有日期字段time和字符字段day,我想利用当前时间减去time中的日期获取中间的天数差值,百思不得其解,求大神给段代码。小的错误代码附上:publicvoidgetd...
现有日期字段time和字符字段day,我想利用当前时间减去time中的日期获取中间的天数差值,百思不得其解,求大神给段代码。小的错误代码附上:
public void getdays() { WindowsFormsApplication1.DataBase sqlhelper = new WindowsFormsApplication1.DataBase(); DataSet dt = new DataSet(); sql1 = "SELECT * FROM dhqgsj WHERE Nu_time = " + pid; dt = sqlhelper.ExecuteDataSet(sql); if (dt.Tables[0].Rows.Count > 0) { DateTime dt2 = System.DateTime.Now; TimeSpan ts = dt2 - dt1; a = ts.Days; sql = "update dhqgsj set Nu_day = '" + a.ToString() + "' where id= " + pid; dt = sqlhelper.ExecuteDataSet(sql); } } 展开
public void getdays() { WindowsFormsApplication1.DataBase sqlhelper = new WindowsFormsApplication1.DataBase(); DataSet dt = new DataSet(); sql1 = "SELECT * FROM dhqgsj WHERE Nu_time = " + pid; dt = sqlhelper.ExecuteDataSet(sql); if (dt.Tables[0].Rows.Count > 0) { DateTime dt2 = System.DateTime.Now; TimeSpan ts = dt2 - dt1; a = ts.Days; sql = "update dhqgsj set Nu_day = '" + a.ToString() + "' where id= " + pid; dt = sqlhelper.ExecuteDataSet(sql); } } 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询