How to Ignor Sunday and Saturdays on a DateTime Picker?
hi,
I need to count the sick leaves in a month, for that i have to ignor Sat-sun on a datetime picker. how to i set the DateTime picker to ignor Sat and Sun?
Assume there are two date time pickers dt1 and dt2 thus there difference will return teh number of days without counting sat-sun
TY in Advance
Answers (1)
0
Hi Petre,
There isn't an automatic way of doing it.
I think the best way will be to count day-by-day in a loop:
int count = 0; for( DateTime d = dt1.Value.Date; d <= dt2.Value.Date; d = d.AddDays(1)) {
if(( d.DayOfWeek != DayOfWeek.Saturday) && (d.DayOfWeek != DayOfWeek.Sunday)) {
++count
}
} return count
|
Please mark this post as an answer if it helps you
Nir