2

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,

  • Can you explain a bit more on this? I use <Where><DateRangesOverlap><FieldRef Name="EventDate" /><FieldRef Name="EndDate" /><FieldRef Name="RecurrenceID" /><Value Type="DateTime">2012-01-30T00:00:00Z</Value></DateRangesOverlap></Where> Instead of <Today/> using the SPUtility you mentioned. However when I run SQL profile the query date is far apart. The date becomes @L4DTP='2013-01-29 16:00:00',@L5DTP='2011-01-29 16:00:01' Not exactly sure why. Is it I need to do something at eventsQuery.CalendarDate = queryDate; Which the queryDate is something like 12/26/2011 12:00:00 AM format. – user6636 Jan 30 '12 at 7:47
1

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.

  • Yeah same here, I've always had to replace it with the same. – Sean Regan Dec 21 '10 at 21:45
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.