Here is the code I use:
SPQuery query = new SPQuery(); query.ExpandRecurrence = true; query.CalendarDate = new DateTime(2013, 1, 1); query.Query = @" <Where> <DateRangesOverlap> <FieldRef Name=""EventDate"" /> <FieldRef Name=""EndDate"" /> <FieldRef Name=""RecurrenceID"" /> <Value Type=""DateTime""> <Year /> </Value> </DateRangesOverlap> </Where>"; var items = list.GetItems(query);
In the case I have an item that starts at 01/01/2012 and ends at 01/01/2030 with a recurrence every Tuesday, the query returns all items from today until today+year. That means that if today is 18th January 2012, the query isn't returning items from 19th January 2013.
What I need are all items in 2013 (I don't care about other year items, but it would be better not to return them for performance issues). What is happening and how can I solve it?
UPDATE: After some tests I have detected a couple strange things:
If I use Year, the query returns what I have explained before.
If I use Month instead, the query returns all single events in CalendarDate's month. Also, it returns some events outside the month (one or two at most).
If I use Today, it returns all single events until today+2years.
I can't understand this behavior, but waiting for a better answer I will call 12 times the query using Month. Luckily, we don't have too many items... I can't