Sharepoint Forum

 
Home » Forum » Sharepoint       Ask a questionRSS Feeds

Date Queries

  Asked By: Jackie Ayala         Date: Jan 03, 2005      Category: Sharepoint      Views: 225
 

Does anyone have a better example of a query to use on an events list that will return the events for a given day?

what I used:
System.Text.StringBuilder qs = new System.Text.StringBuilder();
qs.Append("<Where>");
qs.Append(" <Or>");
qs.Append(" <Eq>");
qs.Append(" <FieldRef Name='EventDate' />");
qs.Append(" <Value Type='DateTime'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(cellDay) + "</Value>");
qs.Append(" </Eq>");
qs.Append(" <And>");
qs.Append(" <Leq>");
qs.Append(" <FieldRef Name='EventDate' />");
qs.Append(" <Value Type='DateTime'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(cellDay) + "</Value>");
qs.Append(" </Leq>");
qs.Append(" <Geq>");
qs.Append(" <FieldRef Name='EndDate' />");
qs.Append(" <Value Type='DateTime'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(cellDay) + "</Value>");
qs.Append(" </Geq>");
qs.Append(" </And>");
qs.Append(" </Or>");
qs.Append("</Where>");

logic: Find everything where the event date is today(cellDay), or (the event date is less than or equal to today and the end date is greater than or equal to today)

However, this fails miserably when trying to use recurring dates, as recurring dates use a special recurrence info field and set the end date to a date years in the future.

Tagged:    

 

1 Answer Found

 
Answer #1       Answered By: Agustin Miranda          Answered On: Jan 03, 2005       

Recurring events  are not stored as dated items in the Events list. They
are stored as the makeup of their metadata. Like, Occurs every other
Thursday, at 8:00 AM, starting on 01/01/2005, ending on 04/01/2005. You
have to work with the metadata to derive the dates. I am unaware of any
OM call to get those dates.

Also, you can use the following to query  for today:
qs.Append(" <Value Type='DateTime'><Today /></Value>");

 
Didn't find what you were looking for? Find more on Date Queries Or get search suggestion and latest updates.


Your Answer
  • Answer should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].