Zhao Tian 博客

C# 筛选日期部分 && 筛选时间部分

2017-12-30 13:28:12


DateTime dtStartTime = new DateTime(2017, 10, 9, 8, 30, 52);
DateTime dtEndTime = new DateTime(2017, 10, 12, 8, 30, 52);
DateTime dtloopStartTime = new DateTime(2017, 10, 12, 8, 0, 0);
DateTime dtLoopEndTime = new DateTime(2017, 10, 12, 23, 0, 0);
DateTime iStartTime = dtStartTime.Date;
DateTime iEndTime = dtEndTime.Date;
int loopStart = dtloopStartTime.Hour;
int loopEnd = dtLoopEndTime.Hour;
DateTime createTime = DateTime.Now;
DateTime modifiedon = DateTime.Now;
if (iStartTime < createTime.Date && iEndTime < createTime && loopStart < createTime.Hour && createTime.Hour < loopEnd)
{
    Console.WriteLine("Do tasks");
}

修改时间 2017-12-30 14:42:27| 阅读(30) |评论(0) |返回首页

评论