Content Query Web Part–Getting Around Always Changing XSLT

Recently I was working on a project where I was creating a Anniversary and Birthday web part and came across the need to show the Birthday not as the typical MM/DD/YYYY but as MM/DD and we did not get anybody riled because now the entire company know they are “52”!

The other issue comes around how SharePoint likes to display dates when using Content Query Web Parts (CQWP). Even though you probably set up the Date/Time field to only display Date when it comes across in a CQWP you will still get the time component zeroed out as you can see in the example below.


The typical way to handle this would be to go in and modify the XSLT and not display this. There are plenty of resources that talk about that. However there are times when we may not have the time or experience to modify the XSLT. This is where calculated columns can come in very handy.

**Note: This ability to use a calculated column is available not only in SharePoint 2010 but also in SharePoint 2007.

To implement go into the list or library and create a new column. Name the column and make sure to select Calculated (calculation based on other columns).


In the Formula section add the following syntax:

=TEXT([Date Column Name Goes Here],”mm/dd/yyyy”)

Leave all other options default and click on OK.


Now when you go to the CQWP use the new text column instead of the older date column in the Fields to Display section and your information should display appropriately.


Your finished product should look like this:



So I found this resource to be beneficial when I was working on this. Enjoy!

MSDN – Calculated Field Formulas