I Have a List Called Alerts with two columns as Start Date and End Date

I am Trying to generate a CAML Query that retrives only cloumns for which alerts should display within that DATE range compare with DateTime.now

1 Answer 1


Your CAML query should look something like this

                <FieldRef Name="EventDate"/>
                <Value Type="DateTime">
                    <Today OffsetDays="-NumDays"/>
                <FieldRef Name="EventDate"/>
                <Value Type="DateTime">
                    <Today OffsetDays="NumDays"/>

Swap out EventDate with whatever date field you're checking, and NumDays with whatever number you're generating to check between. Make sure you keep the quotes around NumDays.

Whenever I want to figure out what a CAML Query should look like I create a list view and filter it in the browser then fire up SP Designer to look at the Query portion.

There are also some online tools out there for figuring out what the query should look like..

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.