Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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)

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

share|improve this question
add comment

1 Answer

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
add comment

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.