When calculating how many days between 2 dates, should you include both dates in the count, or neither, or 1?

Posted by Andy on Programmers See other posts from Programmers or by Andy
Published on 2012-05-31T02:26:49Z Indexed on 2012/05/31 4:48 UTC
Read the original article Hit count: 227

Filed under:

I hope this question is alright to ask here. I am trying to make an algorithm that counts how many days between 2 dates. For example, 3/1/2012 and 3/2/2012. Whats the correct answer, or the most popular choice, and should be the one I use? So in this case, if I don't include both dates I am comparing, its 0. If I include one of them (both the start date), its 1. Lastly, if I include both, its 2. Thanks.

© Programmers or respective owner

Related posts about algorithms