# Date in If Else Column Subtraction

**URL:** <https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117>\
**Category:** Ask for Help\
**Created:** [September 22, 2021, 3:25am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117 "2021-09-22T03:25:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![biha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/biha/32/84110_2.png) [@biha](https://community.glideapps.com/u/biha)\
**Post date:** [September 22, 2021, 3:25am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/1 "2021-09-22T03:25:38Z")

</div>

Hi,

I have a Start Date Column with a value.  
If this value is before First January 2021, I need to call First January 2021 date instead.  
So I used IF Else Column.

I also have End Date Column with a value.  
If this value is after Today, I need to call Now date. And also, I used If Else Column.

Now, I need to calculate the days from Start Date to End Date.  
I can simply subtract End Date with Start Date if its Date Column.  
But now, its If Else Column. It not works if I simply subtract .  
Please help.

---

<div class="post-metadata">

**Author:** ![Nadir\_Abdelrahman\_MD](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nadir_abdelrahman_md/32/5237_2.png) [@Nadir\_Abdelrahman\_MD](https://community.glideapps.com/u/Nadir_Abdelrahman_MD)\
**Post date:** [September 22, 2021, 3:40am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/2 "2021-09-22T03:40:26Z")

</div>

You can use either Excel sheet formula, or glideapp

Here is how to use it in Excel:  
Look at this table: A| B| C| D columns.

| Start Date | End Date | Cut\_of\_Date | Today |
| --- | --- | --- | --- |
| 9/2/2021 | 10/2/2021 | 1/1/2021 | 9/21/2021 |
| 9/2/2019 | 10/10/2019 | 1/1/2021 | 9/21/2021 |

To get:

| If\_Col\_1 | if\_Col\_2 |
| --- | --- |
| 9/2/2021 | 9/21/2021 |
| 1/1/2021 | 10/10/2019 |

If\_Col\_1 Use: =if(A2\<C2,C2,A2) in D column

if\_Col\_2 use: =if(B2\>D2,D2,B2) in F column

---

<div class="post-metadata">

**Author:** ![biha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/biha/32/84110_2.png) [@biha](https://community.glideapps.com/u/biha)\
**Post date:** [September 22, 2021, 3:41am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/3 "2021-09-22T03:41:55Z")

</div>

i need to do in glideapps .

it something like this.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/4/b4754799d4142b29f144466ffea83f2a24bf5f9f.png)

---

<div class="post-metadata">

**Author:** ![biha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/biha/32/84110_2.png) [@biha](https://community.glideapps.com/u/biha)\
**Post date:** [September 22, 2021, 3:55am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/4 "2021-09-22T03:55:11Z")

</div>

Hi Nadir,

Thanks for your response, but i need the total number of days from start date to end date.  
Do you have any ideas?

If in Excel, it is something like down below, but how to do in Glideapps:

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/d/1d361b6537750a2642089ab7a06b65f08280f690.png)

In F2 the formula = =IF(A2\<C2,C2,A2)  
In F3 the formula = =IF(A3\<C3,C3,A3)

In G2 the formula = =IF(B2\>D2,D2,B2)  
In G3 the formula = =IF(B3\>D3,D3,B3)

And To get the answer :

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/6/66b0e89bf232fbdfdd415e592166e294f259b064.png)

the formula for K2 = =G2-F2  
the formula for K3 = =G3-F3

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 22, 2021, 4:45am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/5 "2021-09-22T04:45:41Z")

</div>

Sorry, I just read this very quickly, but… do you just want the total number of days between two dates?

If yes, this is a very simple subtraction in a Glide math column: `End Date - Start Date`  
As long as both columns are date/time columns, then that will give you the difference in days.

---

<div class="post-metadata">

**Author:** ![biha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/biha/32/84110_2.png) [@biha](https://community.glideapps.com/u/biha)\
**Post date:** [September 22, 2021, 5:06am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/6 "2021-09-22T05:06:35Z")

</div>

Yes, you correct.  
But I have the date column in IF Else Column…

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 22, 2021, 5:13am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/7 "2021-09-22T05:13:07Z")

</div>

What does the if-then-else look like?

---

<div class="post-metadata">

**Author:** ![biha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/biha/32/84110_2.png) [@biha](https://community.glideapps.com/u/biha)\
**Post date:** [September 22, 2021, 5:15am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/8 "2021-09-22T05:15:51Z")

</div>

It is something like this:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/9/190acb08cf9ecc3f73403350353522c9d13a98ec.png)

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 22, 2021, 5:20am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/9 "2021-09-22T05:20:34Z")

</div>

Okay, and what do you get when you try to use that in the calculation?

---

<div class="post-metadata">

**Author:** ![biha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/biha/32/84110_2.png) [@biha](https://community.glideapps.com/u/biha)\
**Post date:** [September 22, 2021, 5:22am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/10 "2021-09-22T05:22:26Z")

</div>

It is empty

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/0/8052b311492854ed21d00e65c070caccf15e79be.png)

It is work when use the Date Column , but i really need to use If else column

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/e/fee683aeaa1f8bd4f4ec6a11b0ba63c30d866926.png)

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 22, 2021, 5:32am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/11 "2021-09-22T05:32:03Z")

</div>

Works for me…

 ![Screen Shot 2021-09-22 at 1.30.12 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/4/f4f4a054ea0b012bef9e36b3d5980eef4fd3e835.png)

 ![Screen Shot 2021-09-22 at 1.30.27 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/5/f5c4311fb7c4c327b78b8e1ba9a999344c377e9b.png)

 ![Screen Shot 2021-09-22 at 1.30.41 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/8/c8fca909a00f8cd364b5bd5dab0cea15f87a6322.png)

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 22, 2021, 5:35am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/12 "2021-09-22T05:35:26Z")

</div>

Your “Jan 1st 2021” column - did you create that in Glide or in a Google sheet?  
Check and make sure it’s configured as a date/time column in Glide.  
It looks like it is, but I have found that if you create date/time columns in Google Sheets, you need to edit the column in Glide and apply the correct column type.

---

<div class="post-metadata">

**Author:** ![biha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/biha/32/84110_2.png) [@biha](https://community.glideapps.com/u/biha)\
**Post date:** [September 22, 2021, 5:44am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/13 "2021-09-22T05:44:08Z")

</div>

> [@Darren\_Murphy](#):
>
> Your “Jan 1st 2021” column - did you create that in Glide or in a Google sheet?

I create in Glide straightway .

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [September 22, 2021, 5:47am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/14 "2021-09-22T05:47:54Z")

</div>

Okay, well as I said - I tried it and it seems to work fine, so not sure what’s going on in your case.

---

<div class="post-metadata">

**Author:** ![biha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/biha/32/84110_2.png) [@biha](https://community.glideapps.com/u/biha)\
**Post date:** [September 22, 2021, 5:59am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/15 "2021-09-22T05:59:43Z")

</div>

Hm I’ve check the format in Glide. Seems like the same. hmm no idea.

---

<div class="post-metadata">

**Author:** ![biha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/biha/32/84110_2.png) [@biha](https://community.glideapps.com/u/biha)\
**Post date:** [September 22, 2021, 6:11am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/16 "2021-09-22T06:11:39Z")

</div>

it turn up like this “invalid operation on date/time”

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/2/6293665543e1947b1910a942f9636e5ae3d9cd9f.png)

---

<div class="post-metadata">

**Author:** ![biha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/biha/32/84110_2.png) [@biha](https://community.glideapps.com/u/biha)\
**Post date:** [September 23, 2021, 6:30am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/17 "2021-09-23T06:30:28Z")

</div>

@Darren_Murphy

Darren,

Please help. Do you have any idea why I still cannot subtract that two things.  
Today, I’ve tried using same conditions but in different sheet. But still cannot.  
Do you have any idea why ?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/7/1/71cff7ce8e13a018be66905fb35385410060d3d8.png)

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/e/8e84140abf52f902aa67a6399270fedc6d2ac925.png)

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/4/b42cc8788d7eda6d572e0e1e48fd6ee91bc12a7d.png)

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/3/2/3232c2594f6d9e9568febc0c1b383321d6705bb9.png)

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/5/153d35e02ad62ba4786e122da44c5e68c33c12d6.png)

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [September 23, 2021, 6:33am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/18 "2021-09-23T06:33:34Z")

</div>

if else column will turn date to a text… so math will not work… i will suggest to do another math on these if else to convert back to date

---

<div class="post-metadata">

**Author:** ![biha](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/biha/32/84110_2.png) [@biha](https://community.glideapps.com/u/biha)\
**Post date:** [September 23, 2021, 6:34am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/19 "2021-09-23T06:34:10Z")

</div>

But Darren did well.

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [September 23, 2021, 6:36am UTC](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117/20 "2021-09-23T06:36:40Z")

</div>

is all about initial formatting… so i cant help you without actually seeing the app from inside… but don’ do that… lol i’m not in to grinding now… LOL…  
try to convert dates to numbers…

[Next page](https://community.glideapps.com/t/date-in-if-else-column-subtraction/32117.md?page=2)
