Wednesday, May 27, 2009

Sharepoint birthdays List on Codeplex

Today i have posted my first Codeplex project.
It 's a simple but useful feature.
It about showing birthdays on a Sharepoint (WSS & MOSS) Site

I based this list on a post

Here below there is the post I based my Sharepoint birthday List

As It didn't work as is, I decided to post it working on Codeplex.


_____________________________________________________________________________________


This web part is a very simple but handy part to show coming birthdays of people. You only use standard controls from SharePoint and you do not have to program anything. It also shows how to use some functions which are not directly available in calculated fields but can be used with a simple trick. so far as I know this trick be used for any other function which is not available for calculated fields. The following describes the steps to create this web part.

Choose "Manage Content" from the "Actions" menu. Choose "Create" and create a custom list. Choose "Modify settings and columns" and add the following columns:

Name, single line of text
Birthday, Date and Time

The Trick: You can not use the Today function directly from the calculated field. So we create a dummy column representing the Today function. The credits for this trick are going to Pete Blair.

Today, single line of text

Next we have to create two calculated fields. The first calculated field tranforms the day of birth to a date in the current year. This means that may 19th, 1971 will be may 19th, 2005.

BirthDayThisYear, Calculated, =TEXT(BirthDay,"M/D/")&TEXT(Today,"YYYY")

the second calculated field will calculate the number of days till that date.

BirthDayIsSoon, Calculated, =DATEDIF(Today,BirthDayThisYear,"d")

Now remove the Today column. The calculated fields will use the actual Today function in stead of the Today column. Make sure that whenever you want to change the calculated fields the Today column is created

Create a new view which will only show the columns Name and Birthday. In this view use the following filter settings showing only the birthdays in the next 14 days.

6 Comments:

Blogger Jakob Olsen said...

Remember to set the return value to a number and 0 decimals (BirthDayIsSoon)
Else the filtering want work.

4:05 AM

 
Blogger vamsipraveen said...

Hi
I created as you directed. And i inserted data. It calculated the BirthdayThisYear and BirthdaysSoon.

Next day i seen the site. It still showing the same data as yesterday. Which means its not calculating daily. its calculating only on the day inserted.

Please provide workarround for this problem.

7:58 AM

 
Anonymous Philipp Schumann said...

Fernando, that's a compelling solution! I have linked to an alternative approach (under my name), which is also free but only works for MOSS profiles at this point.

8:11 AM

 
Blogger Sepaka said...

But Why the Column "BirthdayIsSoon" remains unchanged even if the date has changed?

11:52 PM

 
Blogger Sepaka said...

Why "BirthdayIsSoon" column remains unchaged even if the date has changed?

11:53 PM

 
Blogger Bastiaan Kortenbout said...

I've used this solution to calculate the days between the current date and the users birthday, based on a list of users in a custom SharePoint list.

Unaffortunitelly, empty Birthday values occur in my dataset, so I had to take that into account. Also if an users birthday for this year already passed I received a "!#NUM" value.

So therefore I altered the formula's in the calculated fields a little bit.

BirthDayThisYear, Calculated field based on DateTime fieldtype.
Formula: =IF(DateOfBirth<>"";DATE(YEAR(Today);MONTH(DateOfBirth);DAY(DateOfBirth));"")

BirthDayNextYear, Calculated field based on DateTime fieldtype.
Formula: =IF(DateOfBirth<>"";DATE(YEAR(Today)+1;MONTH(DateOfBirth);DAY(DateOfBirth));"")

DaysBeforeBirthDay, Calculated field based on Number fieldtype with zero decimals.
Formula:
=IF(BirthDayThisYear<>"";IF(ISERROR(DATEDIF(Today;BirthDayThisYear;"d"));DATEDIF(Today;BirthDayNextYear;"d");DATEDIF(Today;BirthDayThisYear;"d"));"N/A")

Together with adding and removing the "Today" field trick, this results in a perfect list with a filterable field based on the number of days before a birthday, also if the birthday is actually in the next year.

Btw, you were using comma's in your DATEDIF function. This resulted in an error saying: "The formula contains a syntax error or is not supported." Replacing the comma's with semicolon fixed that for me.

Regards,
Bastiaan Kortenbout

4:34 AM

 

Post a Comment

<< Home