Solved

need CAML help for DVWP

Posted on 2012-03-29
4
503 Views
Last Modified: 2012-08-14
I insertered a dvwp filtered by start time >=current date and end time <='1/23/2013' so it would be easy to find.

I would like the end date to be 13 months from the current date

here is the current code:

selectcommand="&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;And&gt;&lt;Geq&gt;&lt;FieldRef Name=&quot;EventDate&quot;/&gt;&lt;Value Type=&quot;DateTime&quot;&gt;&lt;Today/&gt;&lt;/Value&gt;&lt;/Geq&gt;&lt;Leq&gt;&lt;FieldRef Name=&quot;EndDate&quot;/&gt;&lt;Value Type=&quot;DateTime&quot;&gt;2013-01-23T14:37:34Z&lt;/Value&gt;&lt;/Leq&gt;&lt;/And&gt;&lt;/Where&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;EventDate&quot; Ascending=&quot;TRUE&quot;/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;/View&gt;"

is it possible to do what I want to do?
0
Comment
Question by:sullisnyc44
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
svetaye earned 500 total points
ID: 37783968
Hello,
In general you can use the "OffsetDays" property to get the date.
Unfortunately you can only use days number as a offset, not months:

<Where>
<Geq>
<FieldRef Name="EndDate" />
<Value Type="DateTime">
<Today OffsetDays="390" />
</Value>
</Geq>
</Where>

Please see this for more info:
http://msdn.microsoft.com/en-us/library/ms460496.aspx
0
 

Author Comment

by:sullisnyc44
ID: 37787662
thx. ok - so do I over write my code to read 'selectcommand=...' add your code?

Will it display the date range between the current date and 13 months out?
0
 

Author Comment

by:sullisnyc44
ID: 37789059
if I try to change the commmand to this I get a 'non specific data error'

"&lt;View&gt;&lt;Query&gt;&lt;&lt;Where&gt;&lt;Geq&gt;&lt;FieldRef Name=\&quot;EventDate\&quot; /&gt;&lt;Value Type=\&quot;DateTime\&quot;&gt;&lt;Today OffsetDays=\&quot;390\&quot; /&gt;&lt;/Value&gt;&lt;/Geq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;"
0
 
LVL 11

Expert Comment

by:svetaye
ID: 37789296
This is the exact code, just copy the "selectcommand" property value:

<SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" UseServerDataFormat="True" selectcommand="<Query>
<Where>
      <Geq>
      <FieldRef Name='EndDate' />
      <Value Type='DateTime'>
      <Today OffsetDays='390' />
      </Value>
      </Geq>
</Where>
</Query>" id="dataformwebpart1">
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently came across an issue with a MOSS 2007 deployment where access into some sub-sites were denied, even for the MOSS farm administrators. A bit of background to the setup of this MOSS farm; this was a three server setup, consisting of a fr…
For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question