Home / Community & Support / Knowledge Base / RadControls for ASP.NET and ASP.NET AJAX / Scheduler / 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

Article Info

Rating: Not rated

Article information

Article relates to

RadScheduler     

Created by

 Peter, Telerik

Last modified

 June 16, 2008

Last modified by

 Peter, Telerik


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.");  
        }  
    } 

VB.NET
 Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
        Dim recurrenceString As String 
 
        recurrenceString = "DTSTART:20080603T100000Z" + Environment.NewLine + "DTEND:20080603T090000Z" + Environment.NewLine + "RRULE:FREQ=DAILY;UNTIL=20080906T000000Z;INTERVAL=7;BYDAY=MO,TU,WE,SU" 
 
        Dim parsedRule As RecurrenceRule  
        RecurrenceRule.TryParse(recurrenceString, parsedRule)  
 
        If (parsedRule.Pattern.DaysOfWeekMask And RecurrenceDay.Sunday) = RecurrenceDay.Sunday Then 
            Response.Write("Appointment occurs on Sunday.")  
        Else 
            Response.Write("Appointment occurs does not on Sunday.")  
        End If 
 
    End Sub 





Article Links

Comments

There are no comments yet.
If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.