SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Following CAML Query is giving me all the events for the upcoming two weeks. Does anyone have an idea how to convert the part [Today+14Day(s)] correctly when using the SPQuery class syntax to use the query in my code behind visual web part (

<'FieldRef Name='EventDate' />
<'Value Type='DateTime'>[Today+14Day(s)]<'/Value>
<'FieldRef Name='EventDate' />
<'Value Type='DateTime'>[Today]

share|improve this question
up vote 0 down vote accepted

This is either easy to answer, or I have completely misunderstood what you are asking, so here goes:

In your code-behind, where you are creating the CAML query string, you will need to programmatically construct the date. Something like:

string query = "<query> ...... <Value type='DateTime'>" + DateTime.Today.AddDays(14).ToString("O") + "</Value> .... </query>";
share|improve this answer
All I needed and works fine, Thanks Doc! – Wim Hill Apr 7 '11 at 15:31

Your Answer


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.