Checking given date is holiday or not

Description :


Here i have one holiday master table and its have two columns holiday date and name .
we can save all holidays in holiday master except sunday's.
In dsholiday dataset i am fetching all holiday date from holiday master.
For checking holiday we can pass date into below function.if it's holiday means it will
return true else false.



private bool fnvalidHoliday(DateTime today)
{
bool dayvalid=false;
if(today.DayOfWeek == DayOfWeek.Sunday)
{
dayvalid=true;
}
DataRow[] dr = DSHoliday.Tables[0].Select("holiday_date = '" + today + "' ");
if(dr.Length > 0)
{
dayvalid= true;
}
return valid;

}


Reference: checking given date is holiday or not


Comments

Author: shyamal swaroop07 Aug 2009 Member Level: Gold   Points : 2

Hi friends we can find previousworking day also using below
function


private DateTime fnprevwrking(DateTime dateto)
{

if (dateto.DayOfWeek == DayOfWeek.Sunday)
{
dateto = dateto.AddDays(-1);
fndatevalidTo(dateto);
}
DataRow[] dr = DSHoliday.Tables[0].Select("holiday_date = '" + dateto + "' ");
if (dr.Length > 0)
{
dateto = dateto.AddDays(-1);
fndatevalidTo(dateto);
}

return dateto;

}



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: