# Custom function: YMD_BETWEEN

^{st}and 2

^{nd}characters (01) represent the number of years between the two dates.

^{th}and 5

^{th}characters (02) represent the number of months between the two dates.

^{th}and 8

^{th}characters (03) represent the number of additional days between the two dates, after allowing for the years and months.

**end of the day**for both days.

*The code for the YMD_BETWEN function is included at the end of this blog post.***later**date represents the ending date of its month, YMD_BETWEEN counts full months

**s from that ending date, and the number of days returned is the number of days remaining in the month represented by the earlier date.**

*working backward*^{th}and 29th). In the example, remember that 27FEB2008 is interpreted as representing the

**end**of that date, so there are only 2 days remaining in the month of February 2008.

^{th}through 31

^{st}).

**earlier**date represents the ending date of its month, YMD_BETWEEN counts full months

**from that ending date, and the number of days returned is the day number of the later date.**

*working forwards***25**

^{th}and December

**25**

^{th}), the number of days returned is 0.

**later**date is greater than the day number of the

**earlier**date, full months are counted starting with the day number of the earlier date, and the number of days is the result of subtracting the day number of the earlier day from the day number of the later date.

^{th}) is greater than the day number of the earlier date (15

^{th}). Therefore, Rule 5 counts Sep 15 as 1 month, Oct 15 as 2 months, Nov 15 as 3 months, and Dec 15 as 4 months, then counts 12 days (Dec 16th through 27th).

**plus**(B) the number of remaining days in the month immediately preceeding the month of the later date.

**full calendar months**in between the two dates, then calculate the days as the number of stub days from each of the two dates. The results of this alternate method would be slightly different from the selected method under certain conditions.

^{th}through 31

^{st}) plus 2 days in August, for a total of

**29**days.

^{th}through 30

^{th}) plus 2 days in August for a total of

**28**days.

**Alternate 3**

^{rd}argument:^{rd}argument will calculate differences from the

**beginning**of the earlier date to the

**end**of the later date.

*All rules are adjusted accordingly, as shown in the examples below.*

# Custom Function: MOS_BETWEEN

**1**

^{st}of a month, so we should see something like 1.03225.

**.9354**

**Mos_Between**function produces reasonable results:

**1**

**1.032258065**

__Function Code__