Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to creat a calender event that will be an all day event and will repeat every year from a list that has everyone's birthday. The recurrence works great and so does the All day event.

The problem is when I set newBirthDay["All Day Event"] = 1; the recurrence all of a sudden doesn't put the event in the correct day, but in the next day.

So say your birthday is on the 8th month and 3rd day, it will actually show up on the calender on August 4th and this only happens when I try to make it an All Day Event. If I leave it as normal it will show up on the correct day August 3rd. Anyone have any idea what could cause this? the C# code is included that handles it.

Thanks for looking

newBirthDay = calList.Add();

            newBirthDay["Title"] = "Happy Birthday, " + addBirthday["Title"].ToString();
            newBirthDay["Entry Type"] = "Birthday";

            string recurrence = "<recurrence><rule>" +
                                "<firstDayOfWeek>su</firstDayOfWeek>" +
                                "<repeat><yearly yearFrequency='1' month='" + addBirthday["Month"].ToString() + 
                                                                "' day='" + addBirthday["Day"].ToString() + "'/></repeat>" +
                                "<repeatForever>FALSE</repeatForever>" +
                                "</rule></recurrence>";


            newBirthDay["RecurrenceData"] = recurrence;
            newBirthDay["EventType"] = 1;
            newBirthDay["All Day Event"] = 1;
            newBirthDay["Recurrence"] = 1;
            newBirthDay["EventDate"] = new DateTime(DateTime.Now.Year, int.Parse(addBirthday["Month"].ToString()), int.Parse(addBirthday["Day"].ToString()));
            newBirthDay["EndDate"] = new DateTime(DateTime.Now.AddYears(100).Year, int.Parse(addBirthday["Month"].ToString()), int.Parse(addBirthday["Day"].ToString()));                
            newBirthDay["UID"] = System.Guid.NewGuid();
            newBirthDay["Description"] = "Happy Birthday, " + addBirthday["Name1"].ToString() + "\nbrithday = " + int.Parse(addBirthday["Day"].ToString()) + "|" + addBirthday["Day"].ToString();

            newBirthDay.Update();
share|improve this question
add comment

2 Answers

I had a colleague look at programmatically setting recurrence lately, I can't remember the details of his issue or how he resolved it but basically the "end time" for your events in the series should represent the end of the recurrence.

share|improve this answer
    
Thats not my issue, If you look at my EndDate I add 100 years to it so it'll repeat for 100 years. The only issue I have is when I enable All Day Event it puts it on the next day instead of the day set in EventDate in calendar view. –  user1211 Aug 4 '10 at 12:21
add comment
up vote 0 down vote accepted

Apprently if you set it to an All Day Event it stores the date in UTC time so depending on your timezone it could end up looking like the next day.

Just set newBirthDay["TimeZone"]= -8;

and now it shows up on the correct day in my calendar for my timezone.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.