# If-Then-Else for TIME range

**URL:** https://community.glideapps.com/t/if-then-else-for-time-range/21800
**Category:** Ask for Help
**Created:** [January 26, 2021, 11:56pm UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800 "2021-01-26T23:56:34Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)
#### Post date: [January 26, 2021, 11:56pm UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/1 "2021-01-26T23:56:34Z")

</div>

I’m trying to build an ITE for a range of times where I get “Morning,” “Afternoon” and “Evening” returned but I can’t get it right. I was able to implement a script in my Sheet that worked great but whenever a new row was created, it didn’t implement it - it just stayed in the row above.

I’ve tried basing it off of “If NOW is on or before then (the static time)…” as well as “If morning (based off of the static time) is on or before NOW then…” but I can’t get it. Someone please help!

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [January 27, 2021, 12:01am UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/2 "2021-01-27T00:01:54Z")

</div>

You can go with this.

Create a math column to derive the hour from your time. HOUR(T) with T pointing to the full timestamp.

Then from that hour number, create an If Then Else column.

If Hour is greater than 18 then Evening.  
If Hour is greater than 11 then Afternoon.  
If Hour is greater than 6 then Morning.  
Else Evening.

Something like that.

---

<div class="post-metadata">

### Author: ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)
#### Post date: [January 27, 2021, 12:09am UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/3 "2021-01-27T00:09:15Z")

</div>

So, I’ve got a Math column pulling NOW for the time and I’ve got the time thresholds like this:

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

Should I change the times to 24 hour?

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [January 27, 2021, 12:11am UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/4 "2021-01-27T00:11:56Z")

</div>

If you want a dynamic greeting, then just have one now column, you can keep everything like it is. Then make an hour column like I said, and an If Then Else to generate the greeting.

---

<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: [January 27, 2021, 10:00am UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/5 "2021-01-27T10:00:46Z")

</div>

> [@ThinhDinh](#):
>
> If Hour is greater than 18 then Evening.  
> If Hour is greater than 11 then Afternoon.  
> If Hour is greater than 6 then Morning.  
> Else Evening.

So 5am is evening? 😂 😛

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [January 27, 2021, 10:02am UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/6 "2021-01-27T10:02:44Z")

</div>

Please spare me, I go to sleep very late so 6 is the start of morning for me. 😂😂😂

---

<div class="post-metadata">

### Author: ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)
#### Post date: [January 27, 2021, 4:50pm UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/7 "2021-01-27T16:50:48Z")

</div>

Hey @ThinhDinh - thank you so much for your help!

I feel like I’m missing something here, though:

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

Current time is 0847 and it’s been converted to a whole number using a Math column. I have the ITE column setup and, to test it, I have it setup to populate “Afternoon” after 7 but it will still only show “Morning.” What am I doing wrong? 🤔🤦‍♂️

---

<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: [January 27, 2021, 4:53pm UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/8 "2021-01-27T16:53:37Z")

</div>

Can you please show the configuration of your math column?

---

<div class="post-metadata">

### Author: ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)
#### Post date: [January 27, 2021, 4:54pm UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/9 "2021-01-27T16:54:25Z")

</div>

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

I’ve also had the time pull from NOW with the same result

---

<div class="post-metadata">

### Author: ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)
#### Post date: [January 27, 2021, 4:56pm UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/10 "2021-01-27T16:56:37Z")

</div>

Your IF statement stops after the first true statement. All of your numbers are greater than or equal to zero so it’s always going to return Morning as a result. Flip it around so it checks the largest number first.

---

<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: [January 27, 2021, 4:59pm UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/11 "2021-01-27T16:59:07Z")

</div>

haha, beat me to it… just spotted that!

---

<div class="post-metadata">

### Author: ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)
#### Post date: [January 27, 2021, 5:02pm UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/12 "2021-01-27T17:02:07Z")

</div>

@Jeff_Hager coming through in the clutch! THANK YOU! I was going to post a gif of Nacho Libre telling you that you’re the best but it won’t let me, so I’ll just say it -

**You are the best!**

---

<div class="post-metadata">

### Author: ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)
#### Post date: [January 27, 2021, 5:06pm UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/13 "2021-01-27T17:06:50Z")

</div>

I got ya!

![](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/b/abb52feec1725467650aa46214f2c664300db92d.gif)

---

<div class="post-metadata">

### Author: ![drascon](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/drascon/32/20070_2.png) [@drascon](https://community.glideapps.com/u/drascon)
#### Post date: [January 27, 2021, 5:08pm UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/14 "2021-01-27T17:08:06Z")

</div>

lol, that’s YOU! 😂🤣

---

<div class="post-metadata">

### Author: ![Rosewebstudio](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/rosewebstudio/32/12261_2.png) [@Rosewebstudio](https://community.glideapps.com/u/Rosewebstudio)
#### Post date: [April 26, 2021, 4:32pm UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/15 "2021-04-26T16:32:55Z")

</div>

Implemented today, works a treat 👍

---

<div class="post-metadata">

### Author: ![NoCodeAndy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nocodeandy/32/62530_2.png) [@NoCodeAndy](https://community.glideapps.com/u/NoCodeAndy)
#### Post date: [January 17, 2024, 4:52pm UTC](https://community.glideapps.com/t/if-then-else-for-time-range/21800/16 "2024-01-17T16:52:28Z")

</div>


