笔记

笔记

 //datetable中值为空时
  if (dtCreate_Date.Rows[0]["Create_Date"] == DBNull.Value)
            {
                returnMessageModel.Status = "1";
                returnMessageModel.Code = "";
                returnMessageModel.Message = "测试记录不存在!";
                returnMessageModel.Data = "";
                return returnMessageModel;

            }
            //获取毫秒级时间
            string Create_Date = Convert.ToDateTime(dtCreate_Date.Rows[0]["Create_Date"]).ToString("yyyy-MM-dd HH:mm:ss");
            string Create_Data = Convert.ToDateTime(dtCreate_Date.Rows[0]["Create_Date"]).ToString("yyyy-MM-dd HH:mm:ss.fff");
            //时间相减求小时数
            DateTime startdate = DateTime.Parse(Create_Date);
            DateTime enddate = DateTime.Parse(DateTime.Now.ToString());
            int d = enddate.Subtract(startdate).Hours;
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页