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 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,

share|improve this question
    
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

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
    
Yeah same here, I've always had to replace it with the same. –  Sean Regan Dec 21 '10 at 21:45

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.

share|improve this answer

Your Answer

 
discard

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

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