Using ajax calendar can i write a program to know the number of working days in a given month...if yes how???
I should be able to show the number of working d
ays in a text box..when i select a given month

HELP IS APPRECIATED

THANX IN ADVANCE

Recommended Answers

All 3 Replies

You're on your own for holidays, though; .NET doesn't know which dates are holidays where you live.

int days = 0;
            DateTime sdt = DateTime.Parse("2/1/2009");
            DateTime edt = DateTime.Parse("2/28/2009");
            int dowStart = ((int)sdt.DayOfWeek == 0 ? 7 : (int)sdt.DayOfWeek);
            int dowEnd = ((int)edt.DayOfWeek == 0 ? 7 : (int)edt.DayOfWeek);
            TimeSpan tSpan = edt- sdt;
            if (dowStart <= dowEnd)
            {
                days= (((tSpan.Days / 7) * 5) + Math.Max((Math.Min((dowEnd + 1), 6) - dowStart), 0));
            }
            else
            {
                days=(((tSpan.Days / 7) * 5) + Math.Min((dowEnd + 6) - Math.Min(dowStart, 6), 5));
            }

Just try this simple code in javascript

var startDate = new Date(startdt);
var EndDate = new Date(endDt);
var WorkingDayCount=0;

if(startDate < EndDate)
{
if(startDate.getDay() != 0 && startDate.getDay() !=6)
{
WorkingDayCount++
}
}

Try web2cal to create ajax calendar. its pretty awesome. Use their free version to try building your software before purchasing a commercial one
Site: http://web2cal.com

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.