How to create Calculated Columns in SharePoint to show differences between dates

Home > Blogs > SharePoint > How to create Calculated Columns in SharePoint to show differences between dates

How to create Calculated Columns in SharePoint to show differences between dates

Like This Blog 6 Spike Xavier
Added by October 21, 2013

In this blog I will create a Calculated Column in SharePoint and add it to my blog tasks list to indicate the number of days I am early or if I’m late with due dates.

I created some data for the month of January 2013 and I calculated the number of days my blogs were early. This was done by calculating the difference between the completedDate and the Due Date in days. If the completedDate was later than the Due Date, the blog is late and the string LATE is returned. This is a fantastic use of calculated columns.

Create the custom Datetime Column CompletedDate 


I have added a new column to an out-of-the-box tasks list called CompletedDate and formatted it as date time and added some data to my tasks list. I made sure to add at least one date where the completedDate is later than the Due Date. I customized the default view to only show the relevant columns.(not shown)

Create the Calculated Column 


In the ribbon I click Create Column. For this example I will use a list column.

Choose Calculated Column as the Data Type 


I call my column DaysEarly and choose calculated column as the data type. This opens up the Formula section.

Enter the Formula 


The formula is part typing and part clicking the column options on the right hand side. I have not had good luck typing column names. I type the formulas but when it’s time to insert the column name I always double-click the column name from the Insert Column box on the righ to place it into my formula. This particular formula prefixes the date difference calculation formula just in case I am late and puts in the string “LATE” if I am, otherwise it returns a number of days I am early.

The formula in its entirety is:

IF(ISERROR(DATEDIF(completedDate,[Due Date],”d”)),”LATE”,DATEDIF(completedDate,[Due Date],”d”))

The first part of the formula checks to see if my calculation will return an error and if it does, it will return the value of LATE as the column value, otherwise it will perform the calculation and return the number of days (“d”) between the two dates where the completedDate is earlier than the Due Date as a number.

Validate the Results 


It all looks good. I can see the days early appearing and the one blog I entered as being late has the value of the DaysEarly column set as LATE.

Spike Xavier
SharePoint Instructor – Interface Technical Training
Phoenix, AZ

Videos You May Like

A Simple Introduction to Cisco CML2

0 3902 0

Mark Jacob, Cisco Instructor, presents an introduction to Cisco Modeling Labs 2.0 or CML2.0, an upgrade to Cisco’s VIRL Personal Edition. Mark demonstrates Terminal Emulator access to console, as well as console access from within the CML2.0 product. Hello, I’m Mark Jacob, a Cisco Instructor and Network Instructor at Interface Technical Training. I’ve been using … Continue reading A Simple Introduction to Cisco CML2

Cable Testers and How to Use them in Network Environments

0 735 1

This content is from our CompTIA Network + Video Certification Training Course. Start training today! In this video, CompTIA Network + instructor Rick Trader demonstrates how to use cable testers in network environments. Let’s look at some tools that we can use to test our different cables in our environment. Cable Testers Properly Wired Connectivity … Continue reading Cable Testers and How to Use them in Network Environments

Data Models in Business Analysis

0 200 0

This video is from our PMI-PBA Business Analysis for IT Analysts and Project Managers (PMI-PBA)® Certification now available at Interface Technical Training. Also see Steve’s PMP Project Management Certification Course: Project Management Professional (PMP®) Certification Video Training PMBOK® 6th Edition  Video Transcription: Data Models are part of the elicitation analysis in PMI-PBA. This is the way … Continue reading Data Models in Business Analysis

Write a Comment

See what people are saying...

    Share your thoughts...

    Please fill out the comment form below to post a reply.