用SUM公式,分别求出今天和昨天支出的和和收入的和,然后用总收入减去总支出不就可以了,例如求昨天的SQL语句 string sql1="select SUM(I_InSchool) from 收入表 where I_InDate= 'DateTime.Now.AddDays(-1).ToShortDateString()'"; String Sql2="select SUM(E_InSchool) from 收入表 where I_InDate='DateTime.Now.AddDays(-1).ToShortDateString()"; 然后执行,用一个int类型变量接收相减就可以了。
上面错了应该是 string sql1="select SUM(I_InSchool) from 收入表 where I_InDate= 'DateTime.Now.AddDays(-1).ToShortDateString()'"; string Sql2="select SUM(E_InSchool) from 支出表 where I_InDate='DateTime.Now.AddDays(-1).ToShortDateString()";
string sql1="select SUM(I_InSchool) from 收入表 where I_InDate= 'DateTime.Now.AddDays(-1).ToShortDateString()'"; string Sql2="select SUM(E_InSchool) from 支出表 where I_InDate='DateTime.Now.AddDays(-1).ToShortDateString()";
string sql1="select SUM(I_InSchool) from 收入表 where I_InDate= 'DateTime.Now.AddDays(-1).ToShortDateString()'";
String Sql2="select SUM(E_InSchool) from 收入表 where I_InDate='DateTime.Now.AddDays(-1).ToShortDateString()";
然后执行,用一个int类型变量接收相减就可以了。
string sql1="select SUM(I_InSchool) from 收入表 where I_InDate= 'DateTime.Now.AddDays(-1).ToShortDateString()'";
string Sql2="select SUM(E_InSchool) from 支出表 where I_InDate='DateTime.Now.AddDays(-1).ToShortDateString()";
string Sql2="select SUM(E_InSchool) from 支出表 where I_InDate='DateTime.Now.AddDays(-1).ToShortDateString()";