I came across this interesting requirement today and hence thought of penning down the solution. Please note this solution is for only for CRM 2015 Online Update 1/ CRM 2016. This solution does not target versions below that.
So from the title of the topic, the requirement is very obvious. I need a view which would show all contacts who birthdate falls this week.
So let us together see, how we can reach a solution here.
- · First I create a new field of type datetime called ‘Date of Birth’. You might be wondering there is already an existing called Birth Day in the contact form. Then why I did not use it? There is a reason for this. I will come back to this. As of now just keep going here. Below is the screenshot for the schema definition for this Date of Birth field.
- · Now create a new field called Age of type Whole Number. This would be a calculated field. Below is the screenshot of the calculation for the age field.
- · Create another field called ‘Upcoming Birthday’. The field would be of type ‘Date and Time’ and will also be a calculated field. The schema and calculation formula of the field is shown in the screenshot below.
- · All set and done. Before you leave customizations window, make sure you put the custom field ‘Date of Birth’ on the contact form to capture date of birth of the contact and remove OOB field. Thinking again WHY? Don’t worry I won’t leave in you dark. Will come back to this.
- · Now all you are left is create a view for the contacts with the following view definition
And voila you are done! Wasn’t that easy.
Now coming to the topic, why I did not use the OOB Birth Date field of the contact entity. The reason is because for age calculation I needed to use the Now() function (you can refer to the above screenshots). This Now() function can only be used with date time fields which have a behavior of ‘User Local’. The OOB Birth Day field has a behavior of Date only and hence we could not use it.
Hope this helps! Happy CRMing.