# Excel question

**URL:** <https://boards.straightdope.com/t/excel-question/488406>\
**Category:** Factual Questions\
**Created:** [March 5, 2009, 5:07pm UTC](https://boards.straightdope.com/t/excel-question/488406 "2009-03-05T17:07:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![baileygrrrl](https://avatars.discourse-cdn.com/v4/letter/b/e19b73/32.png) [@baileygrrrl](https://boards.straightdope.com/u/baileygrrrl)\
**Post date:** [March 5, 2009, 5:07pm UTC](https://boards.straightdope.com/t/excel-question/488406/1 "2009-03-05T17:07:01Z")

</div>

In the table below, how do I calculate the # of elapsed days between columns A and B?

20080110 20081125  
20080204 20081210  
20080425 20081125  
20080612 20081023  
20080703 20090218  
20080721 20081212  
20080730 20081209  
20080731 20081125  
20080805 20081115  
20080808 20081024  
20080822 20081117  
20080822 20081110  
20080828 20081120  
20080829 20081024

---

<div class="post-metadata">

**Author:** ![Keeve](https://avatars.discourse-cdn.com/v4/letter/k/f07891/32.png) [@Keeve](https://boards.straightdope.com/u/Keeve)\
**Post date:** [March 5, 2009, 5:25pm UTC](https://boards.straightdope.com/t/excel-question/488406/2 "2009-03-05T17:25:27Z")

</div>

Column C is this:  
=MID(A1,5,2) & “/” & MID(A1,7,2) & “/” & MID(A1,1,4)  
Column D is this:  
=MID(B1,5,2) & “/” & MID(B1,7,2) & “/” & MID(B1,1,4)  
and then Column E is simply:  
=D1-C1

---

<div class="post-metadata">

**Author:** ![cmosdes](https://avatars.discourse-cdn.com/v4/letter/c/a587f6/32.png) [@cmosdes](https://boards.straightdope.com/u/cmosdes)\
**Post date:** [March 5, 2009, 7:08pm UTC](https://boards.straightdope.com/t/excel-question/488406/3 "2009-03-05T19:08:30Z")

</div>

> [@baileygrrrl](#):
>
> In the table below, how do I calculate the # of elapsed days between columns A and B?
> 
> 20080110 20081125  
> 20080204 20081210  
> 20080425 20081125  
> 20080612 20081023  
> 20080703 20090218  
> 20080721 20081212  
> 20080730 20081209  
> 20080731 20081125  
> 20080805 20081115  
> 20080808 20081024  
> 20080822 20081117  
> 20080822 20081110  
> 20080828 20081120  
> 20080829 20081024

1. Change both columns to be “General” Format.
2. Highlight the first column. On the toolbar, click on Data -\> Text to columns -\> Next -\> Next -\> In the upper right hand column set the Column Data Format to “Date YMD”. Do this for both columns.
3. In Column C, set it to be B1 - A1.

---

<div class="post-metadata">

**Author:** ![Keeve](https://avatars.discourse-cdn.com/v4/letter/k/f07891/32.png) [@Keeve](https://boards.straightdope.com/u/Keeve)\
**Post date:** [March 5, 2009, 9:28pm UTC](https://boards.straightdope.com/t/excel-question/488406/4 "2009-03-05T21:28:04Z")

</div>

> [@cmosdes](#):
>
> Highlight the first column. On the toolbar, click on Data -\> Text to columns -\> Next -\> Next -\> In the upper right hand column set the Column Data Format to “Date YMD”. Do this for both columns.

Wow! I’ve seen that dialog before, but only when importing from a text file. I didn’t know it works on stuff that’s already typed in. Way to go! Thanks!

---

<div class="post-metadata">

**Author:** ![Dervorin](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@Dervorin](https://boards.straightdope.com/u/Dervorin)\
**Post date:** [March 5, 2009, 10:24pm UTC](https://boards.straightdope.com/t/excel-question/488406/5 "2009-03-05T22:24:44Z")

</div>

> [@cmosdes](#):
>
> 1. Change both columns to be “General” Format.
> 2. Highlight the first column. On the toolbar, click on Data -\> Text to columns -\> Next -\> Next -\> In the upper right hand column set the Column Data Format to “Date YMD”. Do this for both columns.
> 3. In Column C, set it to be B1 - A1.

After doing that, you can use the undocumented DATEDIF function to get, say, the number of months between the dates. Set C = DATEDIF(A1, B1, “d”) for days, “m” for months etc.

> **[DATEDIF Worksheet Function](http://www.cpearson.com/excel/datedif.aspx)**

---

<div class="post-metadata">

**Author:** ![Uncle\_Brother\_Walker](https://avatars.discourse-cdn.com/v4/letter/u/f08c70/32.png) [@Uncle\_Brother\_Walker](https://boards.straightdope.com/u/Uncle_Brother_Walker)\
**Post date:** [March 6, 2009, 5:16am UTC](https://boards.straightdope.com/t/excel-question/488406/6 "2009-03-06T05:16:30Z")

</div>

Wow. And i thought I was smart.

Too technical for me. I was going to suggest changing the field to ‘date’ format and then sort by that.

::bowing out to the kids table::

---

<div class="post-metadata">

**Author:** ![baileygrrrl](https://avatars.discourse-cdn.com/v4/letter/b/e19b73/32.png) [@baileygrrrl](https://boards.straightdope.com/u/baileygrrrl)\
**Post date:** [March 9, 2009, 2:33pm UTC](https://boards.straightdope.com/t/excel-question/488406/7 "2009-03-09T14:33:37Z")

</div>

> [@cmosdes](#):
>
> 1. Change both columns to be “General” Format.
> 2. Highlight the first column. On the toolbar, click on Data -\> Text to columns -\> Next -\> Next -\> In the upper right hand column set the Column Data Format to “Date YMD”. Do this for both columns.
> 3. In Column C, set it to be B1 - A1.

Excellent thanks! I didn’t know this either and it will come in very handy.
