# Date in If Else Column Subtraction

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 .

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

i need to do in glideapps .

it something like this.

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:

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 :

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

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.

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

What does the if-then-else look like?

It is something like this:

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

It is empty

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

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.

I create in Glide straightway .

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

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

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

@Darren_Murphy

Darren,