10

I am using CAML query for SharePoint calender list. I am able fetch proper daily data. but when i choose weekly, monthly and yearly, it doesn't give me reports as expected. it doesn't take date specified rather it takes start date of present week.

how can i solve this problem?

qryBookings.Query = 
"<Where>
    <And>
        <DateRangesOverlap>
            <FieldRef Name='EventDate'/>
            <FieldRef Name='EndDate'/>
            <FieldRef Name='RecurrenceID'/>
            <Value Type='DateTime'>
                <Week/>
            </Value>
        </DateRangesOverlap>
        <And>
            <Eq>
                <FieldRef Name='Place'/>
                <Value Type='Lookup'>" + d.SelectedItem.Text + "</Value>
            </Eq>
            <Eq>
                <FieldRef Name='Test'/>
                <Value Type='Lookup'>" + R.SelectedItem.Text + "</Value>
            </Eq>
        </And>
    </And>
</Where>";

qryBookings.CalendarDate = DateTime.Parse(txtDate.Text);
qryBookings.ExpandRecurrence = true;
  • Could you add some of your CAML-Query, it would be much easier to solve your problem. Thank you! – Benny Skogberg Aug 20 '14 at 6:42
  • please see my update question – SharePointMan Aug 20 '14 at 7:01
  • Super! I took the liberty to make it more readable. Thank you! – Benny Skogberg Aug 20 '14 at 7:09
  • me too have similar problem, i am trying to generate reports based on start and end date, but reccurent entries are not getting displayed if I don't use <DateRangesOverlap> – Salim Mandrekar Aug 23 '14 at 7:44
1

The weekly approach starts with the first day of current week. I guess there is nothing you can do about this, except always to work on Sunday ;-)

I guess the point is to make a function of your own to compute desire starting and ending date. Then apply the correct "BETWEEN" statement in CAML. With GREATER and LESSER since there is no shortcut.

Hope that helps

0

Not sure why this is not working, but an alternative would be to apply the filtering directly in the CAML Query.

First step would be to decompose the DateTime.Now into its year, month and day parts. Based on that you can generate a Start Date and an End Date and pass those in the CAML, filtering by StartDate (EventDate) and EndDate.

0

You can use a usefull tool called CAML Builder, really helping :) : http://www.u2u.be/Software

0

In CAML query you can use <BeginsWith> tag to solve your problem. You can also use <Leq> or <Geq>.

Refer these below link which may helps you.

0

I am using the old soap service (Lists.asmx, GetListItems) to retrieve calender items for the current month. Used this webservice to be able to retrieve recurrences. My query is very similar to yours except that I am supplying the start date in a different way.

Query:

          <Where>
           <And>
              <Geq><FieldRef Name="EndDate"/><Value Type="DateTime">" + monthStartDate + "</Value></Geq>
            <DateRangesOverlap>
              <FieldRef Name="EventDate" />
              <FieldRef Name="EndDate" />
              <FieldRef Name="RecurrenceID" />
              <Value Type='DateTime'><Month/></Value>
            </DateRangesOverlap>
           </And>
        </Where>

Queryoptions:

        <queryOptions>
            <QueryOptions>
              <ExpandRecurrence>TRUE</ExpandRecurrence>
              <DateInUtc>TRUE</DateInUtc>
             <CalendarDate>" + monthStartDate + "</CalendarDate>
            </QueryOptions>
        </queryOptions>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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