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

I have a list called profile, and this list contains the Birthday field, is a field of type DateTime. I created two fields of type calculated, one gets the day, and the other gets the birthday month of field. And I have to make a query to get the birthdays of the week I thought of mounting a filter like this:

Select Name, Day, Moth from Profile 
Where (Day = 14 And Moth = 10) Or (Day = 15 And Moth = 10) Or (Day = 16 And Moth = 10) 
   Or (Day = 17 And Moth = 10) Or (Day = 18 And Moth = 10)
   Or (Day = 19 And Moth = 10) Or (Day = 20 And Moth = 10)

Only I have no idea how to do this in caml, can someone help me?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

It would be better to create a calculated field BirthdayCheck which contains the birthday, but with a fixed year like 2000. Formular to use: =DATE(2000,MONTH(Birthday),DAY(Birthday))

Then your query would be

Select Name, Day, Moth from Profile  
Where BirthDayCheck => 2000-10-14 and BirthDayCheck <= 2000-10-20

Which in CAML would be

<Where>
  <And>
    <Geq>
      <FieldRef Name="BirthdayCheck" />
      <Value Type="Calculated">2000-10-14T00:00:00Z</Value>
    </Geq>
    <Leq>
      <FieldRef Name="BirthdayCheck" />
      <Value Type="Calculated">2000-10-20T00:00:00Z</Value>
    </Leq>
  </And>
</Where>
share|improve this answer
    
The problem is that I am not able to create this new calculated field returns the following error: No support for formula or it contains a syntax error. –  Tiago Oct 21 '12 at 14:35
2  
If your locale is using , as decimal point you may have to write the formular as =DATE(2000;MONTH(Birthday);DAY(Birthday)) –  Per Jakobsen Oct 21 '12 at 15:16
    
It worked thank you very much for the help! –  Tiago Oct 21 '12 at 19:57
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.