Hi I need to get all user name who is celebrating birthday today based on the value in SPS-Birthday field using Rest API?

How to achieve this?

  • $.ajax({ url: siteUrl +"/_api/search/query?querytext='*'&sourceid='B09A7990-05EA-4AF9-81EF-EDFAB16C4E31'&rowlimit=5&selectproperties='PreferredName,WorkEmail,PictureUrl,Title,Departament,RefinableDate00,Url'&refinementfilters='RefinableDate00:datetime("2000-02-08")'", headers: { Accept: "application/json;odata=verbose" }, });
    – sherin
    Feb 9 '17 at 4:34

I think direct it is not possible what you will need first fetch all site users using below REST URL.

Your Site URL + "/_api/web/siteusers"

Then get account name for all users from above response and generate string like below:

var targerUsers = ["i:0#.f|membership|test.onmicrosoft.com","i:0#.f|membership|dtest1.onmicrosoft.com"];

Then pass this variable in below URL:


Then in response of above query result filter by your requirement.


You can use in conjunction with SharePoint Search REST API as below:


Here , source id = guid of the people data source

You need to map the property SPS-Birthday to one the Refinable properties like RefinableDate00. Check below image.

enter image description here

Once done, wait for the crawl to be completed. In SPO, it takes anything between 24 hours to 1 week ( yes 1 freaking week).

Also important thing to note, the Date is stored something like yyyy-mm-dd. Here, yyyy is always the year 2000.

So in the above query you must form a date from today and then append the year 2000 to it.


Update as per Danny's comment

So today's value can be fetched as below:

String.format("{0:yyyy}-{0:MM}-{0:dd}",new Date(new Date().setFullYear(2000)) );

Pass this value to the REST api and after that process the JSON results :)

  • 1
    Why? use JavaScript hacks. SharePoint provides a String.format function String.format("{0:yyyy}-{0:MM}-{0:dd}",new Date()); sharepoint.stackexchange.com/questions/160806/… Feb 8 '17 at 13:39
  • 1
    To set to a fixed year you have to jump through an extra hoop (because Microsofts .format( ) does not accept milliseconds): String.format("{0:yyyy}-{0:MM}-{0:dd}",new Date(new Date().setFullYear(2000)) ); Feb 8 '17 at 13:42
  • @Danny'365CSI'Engelman - this is awesome ! thanks a lot. Off topic, is there any way i can pass the culture value ? I usually use momentjs for that, would be awesome if its doable using this way. Feb 8 '17 at 15:01
  • Dunno, they say Its America First and The Netherlands second, so (I think) I only should use my own culture ... is probably somewhere in the page context info ? Feb 8 '17 at 15:18
  • hey guys, the query is throwing bad request
    – sherin
    Feb 9 '17 at 4:32

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.