开发者

how to calculate the working days in between two different dates in asp.net

i have two textbox using calaendarExtender and one label.

My needed is if i select two diff开发者_开发百科erent dates in calendar extender the number of working days(excluding Sunday) to be automatically display in the label.

can any one help me..... im new in ASP.net......


What about this:

DateTime start = new DateTime(2010, 12, 1);
DateTime end = new DateTime(2010, 12, 31);

int workdays = 0;
DateTime aux = start;
while(aux <= end)
{
    aux = aux.AddDays(1);
    if (aux.DayOfWeek != DayOfWeek.Sunday)
        workdays++;
}
yourLabel.Text = workdays.ToString();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜