[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 476
  • Last Modified:

SharePoint calculated column error

I have the following formula to calculate day difference between two dates:
=IF(OR(LEN(Date1)=0,LEN(Date2)=0)," ",DATEDIF(Date1,Date2,"d"))

Open in new window

It works great but with one exception. In a very rare situation Date2 can be greater than Date1 and the result will be negative. In this case SharePoint will display an ugly #NUM! error code.

Can you please modify the above to show 0 (zero) instead of the error code if the Date2 is greater than Date1? Thanks!
0
MisUszatek
Asked:
MisUszatek
1 Solution
 
manojceCommented:
Hi,

=IF(OR(LEN(Date1)=0,LEN(Date2)=0)," ",IF(Day(Date1)>Day(Date2),"0",DATEDIF(Date1,Date2,"d")))

Open in new window



Its working in my site.

Thanks,
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now