开发者

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

开发者 https://www.devze.com 2023-01-30 07:46 出处:网络
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 automatic

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

精彩评论

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