V4 Tokens: https://microsoft-search.github.io/pnp-modern-search/usage/search-results/tokens/
I wanted to use the PnP Search web part to get all the birthdays stored in AD (also known as the User Profile Service).
It's easy enough to get the birthday by mapping the SPS-Birthday from the LocalPeopleResults results source, however the issue is that Birthdays don't save year, so when you get the birthday out it will look like 11 July 2000, which when querying become an issue. Unless you use theses Tokens.
For this example and explanation we have Mapped RefinableDate01 with People: SPS-Birthday
- I started by trying to get the Month Birthdays, like this:
- RefinableDate01>=2000-07-01 AND RefinableDate01<=2000-07-31
- But this is not Dynamic, they will only give July's Birthdays.
- I then tried the Today Token
- RefinableDate00>={Today} AND RefinableDate00<={Today}+30
- However because the birthday year is 2000, it will never match
| Query variable | Example / Result |
|---|---|
| {Today+/- <integer value for number of days>} | {Today} - 2014-04-26 {Today+10} - 2014-05-06 {Today-365} - 2013-04-26 |
- Now we know about better Tokens we can use
- RefinableDate00>=2000-{CurrentMonth}-01 AND RefinableDate00<=2000-{CurrentMonth}-31
- This gives us our desire result
| Token | Definition |
|---|---|
| {CurrentYear} | Local date four digits, 2023 |
| {CurrentMonth} | Local month, 1-12 |
| {CurrentDate} | Local date, 1-31 |
| {CurrentHour} | Local hour, 0-23 |
| {CurrentMinute} | Local minute, 0-59 |
| {CurrentSecond} | Local second, 0-59 |
| {CurrentYearUTC} | UTC date four digits, 2023 |
| {CurrentMonthUTC} | UTC month, 1-12 |
| {CurrentDateUTC} | UTC date, 1-31 |
| {CurrentHourUTC} | UTC, 0-23 |
| {CurrentMinuteUTC} | UTC minute, 0-59 |
| {CurrentSecondUTC} | UTC second, 0-59 |