Example of MOSS calculation fields for Month-Year and Quarter-Year from date column

by michaellotter 9/6/2007 2:36:00 PM

Recently I was asked to create new Monthly and Quarterly DVWPs for the "Time Card Management" template.  One of the tasks was to create new columns for the Month and Quarter for DVWPs to group the information by. The Year value was tacked on the end to allow for separate year grouping. Below are the formulas for the columns.

Month-Year

=MONTH([Start Time])&"-"&YEAR([Start Time])

Quarter-Year

=IF(AND(MONTH([Start Time])>=1,MONTH([Start Time])<=3),"1"&" "&YEAR([Start Time]),IF(AND(MONTH([Start Time])>3,MONTH([Start Time])<=6),"2"&" "&YEAR([Start Time]),IF(AND(MONTH([Start Time])>6,MONTH([Start Time])<=9),"3"&" "&YEAR([Start Time]),IF(AND(MONTH([Start Time])>9,MONTH([Start Time])<=12),"4"&" "&YEAR([Start Time])))))

The calculation for the Quarter column was a little tricky because I wanted to determine what Quarter the month was in but I was able to accomplish it by using the SharePoint help and the below blog entry from Mark Kruger.

http://www.sharepointblogs.com/mkruger/archive/2007/06/26/howto-using-sharepoint-calculated-columns-to-display-a-list-item-as-quot-x-quot-days-old.aspx

The SharePoint help helped with the fundamentals and Mark Kruger blog entry helped with the syntax for the Quarter calculation.  Since Mark's entry helped me figure out my problem I figured I would post my calculations hoping it would do the same for someone else.

Cheers

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

MOSS

Related posts

Comments

12/6/2007 12:46:08 AM

Nice job! Glad I could get you pointed in the right direction.

Mark Kruger

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

11/20/2008 3:36:02 PM

Powered by BlogEngine.NET 1.3.0.0
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  November 2008  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar

Recent comments

Tags

Don't show

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008

    Sign in