一 查询插入数据库中的日期
在Access数据库中,关于查询某一个时间段内的数据的问题(有字段属性为 时间/日期 类型的),容易出现的问题就是“#”符号是否缺少了……
C#程序中:access数据库在时间段内查询数据和SQL server中大有出入,access数据库时间字段值两边要加‘#’,而SQL server中则不需要加'#'
Access数据库 时间段内查询数据
//---------------
string startday;//起始日期/时间
string endday;//终止日期/时间
string sqltext = "SELECT SUM([Money]) AS 合计 FROM MoneyType WHERE ([Date] Between #"+startday+"# And #"+endday+"#)";
二 C#获取系统时间
DateTime 数字型
System.DateTimecurrentTime=new System.DateTime();
取当前年月日时分秒 currentTime=System.DateTime.Now;
取当前年 int 年=currentTime.Year;
取当前月 int 月=currentTime.Month;
取当前日 int 日=currentTime.Day;
取当前时 int 时=currentTime.Hour;
取当前分 int 分=currentTime.Minute;
取当前秒