0

I have a list called Profile, and this list contains the Birthday 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?

2 Answers 2

2

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>
2
  • 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, 2012 at 14:35
  • 3
    If your locale is using , as decimal point you may have to write the formular as =DATE(2000;MONTH(Birthday);DAY(Birthday)) Oct 21, 2012 at 15:16
-1

2000(y)-12(m)-14(d) and BirthDayCheck <= 2000(y)-01(m)-14(d)

This query will fail here.. If we are checking for current and next year.

1
  • Hi Chetan, maybe you should use the real year instead of 2000 for the query work, or do you store all birthdays as in 2000 regardless? Dec 21, 2015 at 9:41

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.