SharePoint List Calculated Column - Calculate Business Days

by Oscar 6/23/2008 12:19:00 PM

Ran into a nice little scenario where my client wanted to know how many business days were remaining prior to a Task Due Date. Once I had this date, I built a nice DataViewWebPart (see Figure 3) with the SharePoint Designer! This is what I came up with, hope it helps you!

A) Create a calculated column; call it something like "Days Prior to Due Date" in my case.

b) Paste this value into a Calculated Column, formula
=(DATEDIF(Today,[Due Date],"d"))-INT(DATEDIF(Today,[Due Date],"d")/7)*2-IF((WEEKDAY([Due Date])-WEEKDAY(Today))<0,2,0)+1

C) Make the output type "Single line of text"

NOTE:
At the time of creating this calculated column, you must have another dummy column called "Today", it does not matter what data type it is. Once you create your calculated column, make sure to delete the Today column or your values will not work!

FIGURE 1 – Shows the formula for your calculated column to count only weekdays.

FIGURE 2 – Shows the sample Due Date and the calculated column output (far right)

FIGURE 3 – Shows you a dashboard with some XSL logic in the background to output an image on the left, and the days remaining calculated column value on the far right

Currently rated 3.0 by 1 people

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

Tags:

WSS 3.0 | MOSS 2007 | Calculated Fields | SharePoint Designer | DataViews

Related posts

Comments

6/24/2008 2:12:22 PM

Trackback from Oscar Medina's Blog

SharePoint Designer Workflow

Oscar Medina's Blog

7/14/2008 11:06:04 PM

When using today in a formula, I think it shows the first date of the computer (January 1st, 1899 or so). =weekday([Today)) shows an incorrect day and =DATEDIF([DATEOFTHEEVENT];[today];"d"Wink gives number higher than 39000.

¿How can i use today in formulas correctly?

Thanks in advance.

Javier es

7/20/2008 3:05:45 PM

Javier, thanks for stopping by. Make sure you

a) create a Today (any data type) column, before creating your calculated column.
b) delete the Today after your calculated column is saved!

Oscar us

8/12/2008 11:57:50 AM

Javier, make sure you delete the 'Today' dummy column in order to see the correct calculated date.

Oscar us

9/5/2008 2:23:50 AM

Hi Lauri,

Thanks for stopping by. In XSL you can build an image src using this technique:

<img alt="{@Title}" border="0">
<xsl:attribute name="src">
<!-- if there are amber tasks and no red tasks -->
<xsl:if test="$TotalTasks != $CompletedCount">
<xsl:choose>
<!-- Amber -->
<xsl:when test="$AmberCount &gt; 0 and $NotStartedAndPastDueCount=0 and $RedCount=0">/_layouts/images/ewr214l.gif</xsl:when>
<!-- Red -->
<xsl:when test="$NotStartedAndPastDueCount &gt; 0">/_layouts/images/ewr213l.gif</xsl:when>
<!-- red-->
<xsl:when test="$NotStartedAndPastDueCount &gt; 0 or $RedCount &gt; 0 or $AmberCount &gt; 0">/_layouts/images/ewr213l.gif</xsl:when>
</xsl:choose>
</xsl:if>

<!-- if all tasks are completed -->
<xsl:if test="$TotalTasks = $CompletedCount">
/_layouts/images/ewr212l.gif
</xsl:if>
<!-- if no tasks have been worked on -->
<xsl:if test="$AmberCount = 0 and $RedCount=0 and $CompletedCount=0">
/_layouts/images/ewr226l.gif
</xsl:if>

<xsl:if test="$CompletedCount &gt; 0 and $AmberCount=0 and $RedCount=0">
/_layouts/images/ewr212l.gif
</xsl:if>

</xsl:attribute>
</img>

Oscar us

10/7/2008 1:04:23 AM

Hey Oscar,

Any thoughts on auto recalculating or auto updating the calculated columns. I have to manually update the list item in order to update the value in calculated column.

Regards,
Ritesh

Ritesh us

Add comment


 

  Country flag





Live preview

11/21/2008 3:27:37 PM

Powered by BlogEngine.NET 1.2.0.0
Theme by Mads Kristensen

About Me

Oscar Medina I am a SharePoint Solutions Architect based out of San Francisco, California.
You can read more about me here

E-mail me Send mail
View Oscar Medina's profile on LinkedIn

Calendar

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

View posts in large calendar

Recent comments

Disclaimer

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

© Copyright 2008

Sign in