I believe the "DATEDIF" function will ignore time values so using it will only give you the amount of days difference.
Try this (starting over from scratch):
Column 1: Start Date: type = Date and Time
Column 2: End Date: type = Date and Time
Column 3: Target Duration: type = Single line of text (text entered as Days:Hours:Minutes)
Column 4: Actual Duration: type = Calculated
Formula:
=INT([End Date]-[Start Date])&"days "&INT(MOD([End Date]-[Start Date],1)*24)&"hrs "&INT(MOD(MOD([End Date]-[Start Date],1)*24,1)*61)&"mins"
Column 5: Time Taken: type = Calculated
Formula:
=TEXT(VALUE(INT([End Date]-[Start Date])&":"&INT(MOD([End Date]-[Start Date],1)*24)&":"&INT(MOD(MOD([End Date]-[Start Date],1)*24,1)*61)),"hh:mm:ss")
Column 6: Traffic Light: type = Calculated
Formula:
="<DIV style='font-weight:bold; font-size:24px; color:"&IF([Time Taken]-[Target Duration]=0,"green",IF([Time Taken]-[Target Duration]>0,"red","green"))&";'>•</DIV>"
Column 7: Over-Under: type = Calculated
Formula:
=IF([Time Taken]-[Target Duration]=0,"On-Time",IF([Time Taken]-[Target Duration]>0,"Over","Under"))
Last step: add in the Javascript from Christophe's articles to a CEWP (make sure and drag it below the list) to convert the DIV tags into real html and display the red/green indicators.
After doing this, add in a new item:
Title: Task A
Start Date: 4/13/2009 8:00 AM
End Date: 4/16/2009 2:30 PM
Target Duration: 3:04:00
This will display as:
Title: Task A
Start Date: 4/13/2009 8:00 AM
End Date: 4/16/2009 2:30 PM
Target Duration: 3:04:00
Actual Duration: 3days 6hrs 30mins
Time Taken: 03:06:30
Traffic Light: red
Over-Under: Over
Make a few edits to change the End Date to equal the target duration and then less than the target duration and you should see the traffic light change to green when its on-time (equal to target duration) and under (less than target duration), as well as the over-under text change accordingly.
You may notice that on occasion, the "Time Taken" value may display as 29 or 59 instead of 30 or 00. This is because of how we're counting the starting and ending minutes (SharePoint and its logic). You'll probably only see it if the time is on the half hour, but its just how SharePoint performs the calculation, so dont worry too much about it.
You could probably just use either the "Actual Duration" column or "Time Taken" column since they both represent the same information (just differently), but both could be nice for different views.
Does this get you closer to what "They" want?
- Dessie
(Note - I may need to edit this if the "DIV" stuff doesn't display properly - happens on occasion)