我想在一个月之间找到星期天 [英] I want to find sunday between the month
问题描述
尊敬的先生,
我已经申请了一个想要找到给定月份之间的星期日的应用程序.我有两个文本框,如textbox1和textbox2.第一个文本框的日期如2012年8月8日,第二个文本框的日期如2012年8月31日.因此,请找到该日期之间的星期天.
所以,请先生,给我我的问题的正确答案.
谢谢
Nilesh Gujar
Respected Sir,
I have made an application in which I want to find the sunday between the given month. I have take two textbox like textbox1 & textbox2. First textbox take date like 01/08/2012 & 2nd textbox taken date like 31/08/2012. So find the sunday between this date.
So Please Sir, given me the proper answer of my quesion.
Thanks
Nilesh Gujar
推荐答案
尝试以下操作:
Try this:
// The year (1 through 9999).
// The month (1 through 12).
static int CountSundays(int year, int month)
{
var firstDay = new DateTime(year,month , 1);
var day29 = firstDay.AddDays(28);
var day30 = firstDay.AddDays(29);
var day31 = firstDay.AddDays(30);
if ((day29.Month == month && day29.DayOfWeek == DayOfWeek.Sunday)
|| (day30.Month == month && day30.DayOfWeek == DayOfWeek.Sunday)
|| (day31.Month == month && day31.DayOfWeek == DayOfWeek.Sunday))
{
return 5;
}
else
{
return 4;
}
}
请参考:使用SQL Server查找给定月份中的星期日 [^ ]
类似线程:
如何计算数字asp.net 2.0中一年中的星期日数量 [ CP a> [ google [
Refer: finding sundays in given month using SQL Server[^]
Similar thread:
How to calculate number of sundays in a year in asp.net 2.0[^]
Lot more on CP[^]
..and many more on google[^]
这篇关于我想在一个月之间找到星期天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!