Wednesday, June 29, 2011

Extracting Month and Year from a Date and Time Field

I created a series of of document libraries in Sharepoint 2010 to archive minutes from meetings. I wanted to create a view that grouped the minutes by year and month, but I only wanted users to enter the date of the meeting. I figured out how to extract the month and year from the date column and display those as separate columns.

After creating a new document library, I created a Date and Time column named Date.

Then I created a Calculated (calculation based on other columns) column named Month. Since I didn't want the months displayed in alphabetical order, I also pulled the numeric value of the month.

Month formula:

=TEXT([Date],"mm")&" "&TEXT([Date],"mmmm")

Formula output:

05 May

Finally, I created a Calculated (calculation based on other columns) column named Year.

Year formula:

=TEXT([Date],"yyyy")

Formula output:

2011

Now that I had year and month columns, I created a view that grouped by Year (descending) then Month (decending).

This site helped me get started: http://www.sharepointboris.net/2009/05/get-the-month-name-in-calculated-column/

3 comments:

  1. Thanks this works however it doesnt always do the calculation correctly I am extracting the date from the created column and for some reason it defaults to Dec.

    ReplyDelete
  2. Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.
    Sharepoint 2010 Archiving

    ReplyDelete
  3. Works great, thank you!!

    ReplyDelete