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 (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.aspx)

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

1 Answer 1


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>";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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