Question

I have the following CAML query for SP2003

SPQuery qry = new SPQuery();
qry.ExpandRecurrence = true;
qry.CalendarDate = DateTime.Now.Date;

qry.Query = "<Where><And><DateRangesOverlap><FieldRef Name=\"EventDate\" /><FieldRef Name=\"EndDate\" />" +
"<FieldRef Name=\"RecurrenceID\" /><Value Type=\"DateTime\"><Today /></Value></DateRangesOverlap>" +
"<Eq><FieldRef Name=\"User\" LookupId=\"true\" /><Value Type=\"Integer\">" + uvEmployee.LookupId.ToString() + "</Value></Eq></And></Where>";

Which returns me an all day event which is occuring tomorrow. Am I missing something?

Thanks,

Was it helpful?

Solution

Maybe it is just me, but I have not had much luck getting the Today to work in my environment. I use "sputility.createiso8601datetimefromsystemdatetime" on todays date and this always works.

OTHER TIPS

The string value from the column is in iso8601 format, and is in correct Zulu time.

<Today/> string value from CAML is in the same format, but is the current date time of the server time zone.

Compare the 2 values directly and you'll be out by however many hours your current time zone is.

Using

SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Now)

as mentioned above, will give the compatible "today" string value to compare to the column value.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top