日期范围检查...... [英] Date range checking...
本文介绍了日期范围检查......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以知道我的日期是星期五吗?那么如果有周六或周日,如何在接下来的4天内查看?(右边应该有...)thks ..
Hi, may i know if i have a date which is Friday. Then how do i check within the next 4 days if there is Saturday or Sunday?(by right it should have...) thks..
string datetime = txtEffectiveDate.Text;
var dt = DateTime.Parse(datetime).DayOfWeek;
if (dt == DayOfWeek.Friday)
{
}
推荐答案
这是一个示例代码
here is a sample code
DateTime dt = DateTime.Now;
int range = 4;
int offCount = 0;
for (int i = 1; i <= range; i++)
{
if (dt.AddDays(i).DayOfWeek == DayOfWeek.Saturday || dt.AddDays(i).DayOfWeek == DayOfWeek.Sunday)
offCount++;
}
好吧,如果当前日期是星期五,则接下来的两个日期将始终是星期六和星期日。我在这里遗漏了什么吗?
Well, if current date falls on Friday, next two dates will always be Saturday and Sunday. Am I missing something here?
这篇关于日期范围检查......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文