Happy birthday

In outlook you may keep the contacts. For some of these outlook contacts you may have birthdays and for others you may not. What if you want to find all the people with a birthday in your Power Automate flows.

Yesterday I had a chat with fellow MVP, Ed Gonzales, and author of The Flying Polymath about this problem. As we will see in the post below selecting null values for dates can be tricky.

Get contacts action

You could use the Get contacts to get all your contacts.

As a simple flow I only need two steps. A trigger that starts my flow and a Get Contacts (v2) action. The Get contacts actions has a filter Query field available where I can filter my contacts.

oData Filter for Contacts action

When I run this flow without any filters specified I will get the birthday field returned, this will will give me the date that I want in the standard format that Flow uses.

Outlook contacts with a birthday

And you will find some birthdays not set and a value of null is being returned.

Outlook contacts without a birthday

Filtering outlook contacts by null

The obvious way of filtering the birthday field is by using the odata filter and deselecting all the contacts with a null valued birthday. You would exe3pct that the following will work:

birtday ne null

This however doesn’t work. as null and birthday have a different data type. The Flow action will even return a “The specified date isn’t valid”. The Get contacts action is not complaining about the null value in my data. It is complaining about the null value in my query.

The specified date isn't valid when supplying a filter

This means that we will need to find a way to compare my date field with a date value as the types of the data will need to match.

Comparing dates

As already mentioned in a previous OData filter post, filtering on dates can be tricky. We can do something like this:

birthday ge <a long time ago>

In my example below I used a base date of 1800-01-01, but I could have picked any date. We do not need to add the time. Although there is no harm done if you did add the time as well.

Filter by a date

This example shows that

birthday ge 1800-01-01

will give me all the contacts with a birthday after 1800-01-01.

 

 

 


Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe to get the latest posts sent to your email.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading