<div dir="ltr"><div>This is my first post on this mailing list, so please bear with me.</div><div>I used to do date calculations like this in the '80s when I was writing Real Estate software.</div><div><br></div><div class="gmail_extra">
<div class="gmail_quote">On Tue, 12 Nov 2013 20:33:00, waldo kitty wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
[...]<br>the real question is this:<br>
<br>
   what do we count? the starting day, the ending day, both days or neither day?<br></blockquote><div><br></div><div>There are two types of days-between-dates calculations: Inclusive and Exclusive.</div><div><br></div><div>
Generally, the starting day should be considered the first day of the calculation.</div><div><br></div><div>With an Inclusive calculation, the ending day is counted.</div><div>With an Exclusive calculation, the ending day is not counted -- it is considered to be the first day of the following period.</div>
<div><br></div><div>In Real Estate for example, date calculations are Inclusive.</div><div>So a 1-week rent payment that starts on Monday 1 January 2007 ends on Sunday 7 January 2007.<br></div><div>Therefore an Inclusive DateDiff calculation between 1/01/2007 and 7/01/2007 would return 7 days.</div>
<div>Whereas an Exclusive calculation would return 6 days.</div><div><br></div><div>Similarly, when calculating a person's age.</div><div>A baby born on 1/01/2007 would be 7 days old on 7/01/2007.</div><div><br></div>
<div>As I recall, Exclusive dates seem to be more applicable to financial calculations.</div><div>For example, an Exclusive DateDiff calculation between 1/01/2007 and 1/04/2007 would return 3 months (not 3 months and 1 day).</div>
<div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">then we have another question:<br><br>
   is dayM in monthY a one month difference to dayM in monthX and<br>   monthZ? monthX, monthY, monthZ are any three consecutive months<br>   in linear order within one year or crossing two years<br><br>once the rules are chosen, then we have something to work with...<br>
</blockquote><div><br></div></div><div>This is a topic that has some tricky boundary conditions.</div><div><br></div><div>Generally the rule is easy for days 1-27 in every month: </div><div>The Inclusive DateDiff between day M in month 1 and Day M-1 in month 2 returns 1 month.</div>
<div>e.g. between 28/01/2007 and 27/02/2007.</div><div><br></div><div>However the rules get muddy with days 28-31. i.e. the "last few" days of every month.</div><div><br></div><div><div>For example, an Inclusive DateDiff calculation between 29/01/2007 and 28/02/2007 should return 1 month.</div>
<div>In my opinion, an Inclusive calculation between 30/01/2007 and 28/02/2007 should also return 1 month.</div><div>And so should an Inclusive calculation between 31/01/2007 and 28/02/2007.</div><div><br></div></div><div>
In fact, we used to call these "calendar months" to differentiate them from "other" months that might always be defined as having perhaps 30 days.</div><div><br></div><div>So as you see, there is no real hard answer to your question. It probably depend on what you are trying to achieve.</div>
<div><br></div><div>Lex</div><div><br></div><div><br></div></div></div></div>