Hi All,

I'm terribly sorry if this is not the right place to post this problem I'm facing but I've been trying to find a solution for this issue for more then a week and posted it on some forums but still no answer... I decided to give Channel9 a try Smiley

If it helps I'm using Windows Mobile 2003 on my PPC.

I'm trying to write a code to get all appointments for a specific date span. Everything seems to go ok, I also get many appointments that are really inside this dates span, but it seems that some, not all, of the reoccurring appointments I get back are not the right occurrence within the desired span.

This means that if I have a monthly reoccurring appointment and I'm trying to get all appts in the April span, I get the occurrence for May. This is not for all appts. there are many reoccurring appts that I get correctly. I've been testing this issue for a while and I have no clue.

I have a guess that something on my Appointments Database is wrong, because if I change something in one of these appts and exit from the calendar then it is fixed! and now I get the right occurrence, no matter if I closed the program and run it again, it seems that now the problem is fixed!, It might also be something with ActiveSync because after change a specific appt and after this appt worked fine, I hard-reseted my device and synced again all the appts data, and now this appt was all ok, this means that the activsync synced my change in the DB and fixed the problem....

Below is the code part I use for the Find statement.
I would highly appreciate any idea .... 10'x.



TCHAR title_date_first[MAX_LOADSTRING] = {0};
TCHAR title_date_last[MAX_LOADSTRING] = {0};

GetDateFormat(LOCALE_USER_DEFAULT,LOCALE_NOUSEROVERRIDE,tSysTimeStart,NULL,title_date_first,254);
GetDateFormat(LOCALE_USER_DEFAULT,LOCALE_NOUSEROVERRIDE,tSysTimeEnd,NULL,title_date_last,254);

wsprintf (str, TEXT ("[Start] <= \"%s\" AND [End] >= \"%s\""),title_date_last, title_date_first);


hr = polApp->GetDefaultFolder(olFolderCalendar, &pFolder);
if (!SUCCEEDED(hr)) {
return 0;
}

hr = pFolder->get_Items(&pItems);
if (!SUCCEEDED(hr)) {
return 0;
}

hr = pItems->Sort (TEXT("[Start]"), FALSE);
if (!SUCCEEDED(hr)) {
return 0;
}

hr = pItems->put_IncludeRecurrences(TRUE);
if (!SUCCEEDED(hr)) {
return 0;
}

hr = pItems->Find(str, (IDispatch **) &pAppointment);


I  forgot to mention that for the "Problematic" appts I always get the next occurrence.

This means that if this appts occure every month I will get next month's occurrence.

Any reply will be highly appreciated!

10'x Amit.