 Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Unique Date Displays.

# Unique Date Displays by Allen Wyatt
(last updated December 8, 2018)

Jon requested help on how to subtract two dates and display the result such that the years were on the left of the decimal and the months on the right. Thus, if you subtracted January 7, 1991 from August 12, 2019, the result would be 28.7.

The easiest way to do this is to simply do your date subtractions as regular, and then use a custom format to display the result. For instance, if the lower date were in cell A2 and the higher date in B2, you could use the following formula in C2:

```=B2-A2
```

You would then follow these steps to format the display of the result in cell C2:

1. Select the cell. (In this case, cell C2.)
2. Display the Home tab of the ribbon.
3. Click the small icon at the lower-right corner of the Number group. Excel displays the Format Cells dialog box.
4. Make sure the Number tab is selected. (See Figure 1.)
5. Figure 1. The Number tab of the Format Cells dialog box.

6. In the Category list, at the left side of the dialog box, choose Custom.
7. In the Type box, at the left of the dialog box, enter the following format: yy.m
8. Click on OK.

The result is that C2 shows the number of years to the left of the decimal and the number of months to the right. The problem with this is that it will always vary the number of months from 1 to 12, rather than 0 to 11, as one would expect if you were looking for elapsed months. (Hence, the result of 28.8 in C2.)

To overcome this, you could enter the following formula in cell C2:

```=(YEAR(B2)-YEAR(A2))+(MONTH(B2)-MONTH(A2))/100
```

This formula returns the number of years on the left of the decimal and the number of months on the right. (The result is 28.07 in C2.)The months are always expressed using two decimal places, however. If you wanted to make sure that the months were expressed with no leading zeros, then you would use this formula variation:

```=VALUE(ABS(YEAR(B2)-YEAR(A2)) & "." & ABS(MONTH(B2)-MONTH(A2)))
```

The result in C2 is now 28.7.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11057) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Unique Date Displays.

##### Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

##### MORE FROM ALLEN

Configuring Spell Check for Internet Addresses

When writing technical documents, URLs are a common thing to include in your text. Normally Word will mark these as ...

Discover More

Invisible Macros

When configuring Word, you may want to add macros to either menus or toolbars. If you can't find your macros while doing ...

Discover More

Editing PivotTables without Underlying Data

If you ever try to edit a PivotTable and get an error that tells you that the "underlying data was not included," it can ...

Discover More Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

##### More ExcelTips (ribbon)

Rounding to the Nearest Quarter Hour

When entering times in a worksheet, you may have a need to round whatever you enter to the nearest 15-minute increment. ...

Discover More

Calculating a Sum for a Range of Dates

If you use Excel to track information based on dates, you may wonder how to get a sum for only certain dates that you ...

Discover More

Parsing Non-Standard Date Formats

When you load data into Excel that was created in other programs, the formatting used for some types of data (such as ...

Discover More
##### Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is six more than 1?

2019-05-08 14:42:30

Dennis Costello

Another problem with =VALUE(ABS(YEAR(B2)-YEAR(A2)) & "." & ABS(MONTH(B2)-MONTH(A2))) - it gives the wrong answer when B2 is earlier in the year than A2. For instance, if A2 contains 9/13/2018 and B2 5/8/2019, there are 8 months and no full years between those two dates. The simple "B2-A2" approach shows this properly as "00.8", but the formula gives 1.4.

=VALUE(YEAR(B2) - YEAR(A2) - (MONTH(A2) > MONTH(B2)) & "." & MONTH(B2) - MONTH(A2) + (MONTH(A2) > MONTH(B2)) * 12)

This only gives sensible answers when B2 is later than A2, but that is consistent with the original problem statement. Clearly one could build a formula around =IF(MONTH(A2) > MONTH(B2), ..., ...) but I like to use the fact that TRUE becomes 1 and FALSE becomes 0.

Interestingly, the B2-A2 approach yields 00.2 when the dates are for instance 1-Apr and 31-May of the same year (i.e., it rounds the interval to the closest number of months) but the other formulas yield 0.1 (because May is only 1 month later than April).

2018-12-11 20:01:17

Peter Atherton

The DAteDif function has been done somwhere else on this site. But here is a solution using it.

=DATEDIF(A1,B1,"y")+(DATEDIF(A1,B1,"ym")*0.01)

2018-12-10 18:37:07

Yvan Loranger

Problem with =VALUE(ABS(YEAR(B2)-YEAR(A2)) & "." & ABS(MONTH(B2)-MONTH(A2))) is that diffs of 1 & 10 months would both appear as .1 (:

##### This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.