SentForTranslationDate 和TranslationDueDate 这两个是时间DateTime dtStart = DateTime.Parse(SLAword.Tables[0].Rows[i]["SentForTranslationDate"].ToString());
DateTime dtEnd = DateTime.Parse(SLAword.Tables[0].Rows[i]["TranslationDueDate"].ToString());
要转换成DateTime 类型,后面他俩要相减。这些都没有问题,但是有一条数据的TranslationDueDate这个值是NULL。 现在老是出现String was not recognized as a valid DateTime. 我在前面也加判断了 if(!SLAword.Tables[0].Rows[i]["TranslationDueDate"].Equals("")&& !SLAword.Tables[0].Rows[i]["SentForTranslationDate"].Equals("")&&!SLAword.Tables[0].Rows[i]["TranslationDueDate"]!=NULL&& !SLAword.Tables[0].Rows[i]["SentForTranslationDate"]!=NULL 才会执行, 否则跳出。但是我加了那判断他还是会进来,然后说String was not recognized as a valid DateTime ,这是为什么???怎样才能不让他进来??
DateTime dtEnd = DateTime.Parse(SLAword.Tables[0].Rows[i]["TranslationDueDate"].ToString());
要转换成DateTime 类型,后面他俩要相减。这些都没有问题,但是有一条数据的TranslationDueDate这个值是NULL。 现在老是出现String was not recognized as a valid DateTime. 我在前面也加判断了 if(!SLAword.Tables[0].Rows[i]["TranslationDueDate"].Equals("")&& !SLAword.Tables[0].Rows[i]["SentForTranslationDate"].Equals("")&&!SLAword.Tables[0].Rows[i]["TranslationDueDate"]!=NULL&& !SLAword.Tables[0].Rows[i]["SentForTranslationDate"]!=NULL 才会执行, 否则跳出。但是我加了那判断他还是会进来,然后说String was not recognized as a valid DateTime ,这是为什么???怎样才能不让他进来??
或者
DateTime dtStart, dtEnd;
DateTime.TryParse(Convert.ToString(SLAword.Tables[0].Rows[i]["SentForTranslationDate"]), out dtStart);