# Date Format: Subtract two dates and convert to Y-M

#### krbosie

##### New Member
Hi there, I have two cells with dates in them:
eg.
cell k11 has 2009-10-23 in it and cell l11 has 2011-10-13.
I have subtracted the two to get an answer. The answer it gives is 2-1 (2 years and 1 month - This is clearly wrong.
(I used the following formula:
=YEAR(L11)-YEAR(K11)+MIN(0,SIGN(MONTH(L11)+MONTH(K11)))&"-"&MONTH(L11)-MONTH(K11)-MIN(0,SIGN(DAY(L11)-DAY(K11)))+MIN(0,SIGN(MONTH(L11)-MONTH(K11)))*-12&""

How do I do it? What have I done wrong? The answer must be in that exact format: 1-11. I am not interested in the days.

### Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
=DATEDIF(K11,I11,"y")&" - " &DATEDIF(K11,I11,"ym")

Thanks for the reply: I receive an error, #num - Should I format the cell to something different? I'm using Excel 2010.

Working here

=DATEDIF(K11,I11,"y")&" - " &DATEDIF(K11,I11,"ym")

Excel Workbook
IJKL
1113/10/2011*23/10/20091 - 11
Sheet1

Yes, Got it - it works - many, many thanks.

Replies
10
Views
777
Replies
9
Views
507
Replies
7
Views
443
Replies
3
Views
539
Replies
5
Views
630

1,196,126
Messages
6,013,604
Members
441,777
Latest member

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

### Which adblocker are you using?

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

### Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back