New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
How to check if an appointment occurs on a particular day of the week
#HOW-TO Check if an appointment occurs on a particular day of the week
DESCRIPTION
The code sample below parses a recurrence rule and checks if the recurrent appointment occurs on Sunday.
SOLUTION
C#
protected void Page_Load(object sender, EventArgs e)
{
string recurrenceString;
recurrenceString = "DTSTART:20080603T100000Z" + Environment.NewLine + "DTEND:20080603T090000Z" + Environment.NewLine + "RRULE:FREQ=DAILY;UNTIL=20080906T000000Z;INTERVAL=7;BYDAY=MO,TU,WE,SU";
RecurrenceRule parsedRule;
RecurrenceRule.TryParse(recurrenceString, out parsedRule);
if ((parsedRule.Pattern.DaysOfWeekMask & RecurrenceDay.Sunday) == RecurrenceDay.Sunday)
{
Response.Write("Appointment occurs on Sunday.");
}
else
{
Response.Write("Appointment occurs does not on Sunday.");
}
}