Calculating Days Between Dates

M

martins

I use the following formula to calculate the days between dates and to
return zero when dates are the same –

=IF(OR(A1="",A2=""),0,DATEDIF(A1,A2, "d"))
How would I also allow for the eventuality where the date in cell A2 is
earlier than A1 and where the result would then be a minus figure ?

At present the formula returns a "Num" error when this happens
 
B

Bill Ridgeway

By adding to your formula-

=IF(A2<A1,"Error",IF(OR(A1="",A2=""),0,DATEDIF(A1,A2, "d"))

will trap the error and return the word "Error" (or whatever you want)

Regards.

Bill Ridgeway
Computer Solutions
 
D

Dave Peterson

If you're just counting the days between dates:

=a1-a2

(but format it as a number or general.)
 
M

martins

Tried this but doeasnt seem to work or maybe I'm entering the formula
incorrectly - are you suggesting to substitue part of the formula ar as
an add in? could you clarify the whole formula

Thanks
 
D

Dave Peterson

I'm just suggestion that you subtract one date from the other. You could add
your checks like:

=IF(OR(A1="",A2=""),0,a2-a1)
 
F

FSt1

hi,
Try this. drop the dateif part and just use the cell addresses
=IF(OR(A1="",A2=""),0,A1-A2))

regards
FSt1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top