# Math Date function use

**URL:** <https://community.glideapps.com/t/math-date-function-use/37610>\
**Category:** Ask for Help\
**Created:** [January 24, 2022, 3:21pm UTC](https://community.glideapps.com/t/math-date-function-use/37610 "2022-01-24T15:21:33Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 24, 2022, 3:21pm UTC](https://community.glideapps.com/t/math-date-function-use/37610/1 "2022-01-24T15:21:33Z")

</div>

I have a control record where I get the current date using a MATH column.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/d/adf83f84e1a841069a87872f768bfa115e601993.png)

Then I do some other columns to whittle it down to just the Month and Day (think of a birthday which repeats every year, so the year is not significant), then I set up a relation between that day and a Trimmed Lowercase field in my list of “Feasts”. The relation seems to work.

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

Then I set up some columns in my user table, because that table seems to be able to be referenced everywhere (unlike my Control Table). That gives me my Feast ID. So far so good.

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

But when I go to the Feast table, any attempt to user the Feast ID in the user table (while it seems to work in the table itself), does not seem to work in the Filter or “visible” for the tab kind of tests. You can see “user feast relation” is “not empty” in one record, but no records show up in my list when I reference “not empty” on that column. I am actually going to have that a detail screen, but used a list for illustration purposes.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/f/4f3d367702decae6745011cf88f4853c8d89a75f.png)

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

This may seem to be a convoluted way to get here, but I had originally tried just matching my Trim LC Date column with the Trim LC Date column in my user record, and that didn’t give a match either, so that’s when I started setting up relations to see if I could work around that. The two dates obviously “match”. “january 24” in the feasts table and “january 24” in the users table. Is there some issue with the fact that it comes from a math column and not a text column? That’s why I thought I could work around it by using relations.

Why the control record? I figured it would be faster (if I have 3000 users) to do all the computed columns in one row and use the final results in my user table rather than have all the computed columns on every user row. That’s just my way of thinking because I don’t know if Glide only does the computed columns for the currently logged in user, or for all users in the table (like I see in my editor).

However, the results (or lack of results) are the same if I move all the computed columns to the user table – it still does not “match” correctly or filter correctly.

---

<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 25, 2022, 12:19am UTC](https://community.glideapps.com/t/math-date-function-use/37610/2 "2022-01-25T00:19:59Z")

</div>

> [@David\_Gabler](#):
>
> Then I do some other columns to whittle it down to just the Month and Day (think of a birthday which repeats every year, so the year is not significant), then I set up a relation between that day and a Trimmed Lowercase field in my list of “Feasts”

Firstly I think you can have just one column to get to the trimmed month & day here, instead of 2. Are you using experimental code column for this? Or some JavaScript?

For your filter, what is your setting for this relation?

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

I’m thinking you could have the setup like you did originally, just inside the Users table, then use that same relation (set it to multiple match) as your source to display, not having to filter anything else.

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 25, 2022, 3:49am UTC](https://community.glideapps.com/t/math-date-function-use/37610/3 "2022-01-25T03:49:44Z")

</div>

> [@ThinhDinh](#):
>
> Firstly I think you can have just one column to get to the trimmed month & day here, instead of 2. Are you using experimental code column for this? Or some JavaScript?

Well, I was using the Lowercase and Trim Whitespace “text” functions. But I have removed all that – all of it was just workarounds to try and make it work. I’ve reduced it to its simplest components.

Here, I have moved everything to the User table:

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

And in my Feast table, I have these columns (where Month Day is a lookup based on the User Feast Relation):

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

Well, and I think I can see why the filter fails – here I am simply trying to display “Month Day” in my LIST, to verify what it is, and you can see that Month Day (the lookup) does not display… It also does not work as part of the filter.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/b/4b740996ddaeff5bedf0532542ae7e8e0871bc3a.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:** [January 25, 2022, 4:41am UTC](https://community.glideapps.com/t/math-date-function-use/37610/4 "2022-01-25T04:41:41Z")

</div>

I’m not sure that I have a solution for you, but I have a couple of observations and a suggestion.

Firstly, I have a niggling feeling that your math/split text/single value approach might be tripping things up. I’ve been playing around trying to replicate your setup, and it “works”, but one thing I noticed is that when I take the Single Value month/day column and display it in a component, it appears as mm/dd/yyyy, even though it looks like “January 25” in the Data Editor. This makes me suspicious that what you see in the data editor is not the “true” value.

So, here is something to try: take that Single Value MonthDay column, and pass it through a template column, using it as a replacement value. This will force it to be a string, and eliminate the concern above. You’d need to do that in both tables.

My other comment is that I don’t really see the point of the relation/lookup that you have in your GF Feasts table? Couldn’t you just use a Single Value column to take the Month Day value from your GF Users table and apply it to all rows? Actually, for that matter - if all you’re wanting to do is filter the records based on the current date - why not just do everything in the GF Feasts table? (I guess there is a larger context that I’m missing).

---

<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:** [January 25, 2022, 4:51am UTC](https://community.glideapps.com/t/math-date-function-use/37610/5 "2022-01-25T04:51:27Z")

</div>

if you are trying to filter the math column based on text columns… it will not work… convert all columns to text first… i.e when you are extracting a month from the date, using a math column… it will be still a full date

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 25, 2022, 4:52am UTC](https://community.glideapps.com/t/math-date-function-use/37610/6 "2022-01-25T04:52:36Z")

</div>

> [@Darren\_Murphy](#):
>
> if all you’re wanting to do is filter the records based on the current date - why not just do everything in the GF Feasts table?

You weren’t missing any context, except that when I have “universal” values, that I may want to use against other tables, my tendency is to put them in a central location --in this case the “user” table, since it is the only table Glide will always let me access. At any rate, when I had these columns set up in the user table, Glide did not do the “is” correctly. But when they are both in the same table, Glide does it right, it seems. I will have a go at your suggestion to use a template column tomorrow. It’s too late tonight, but you can see that it works if it’s all in the same table. I really need it in the user table because I may/probably will implement other functions concerning the date, and it should be central.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/f/1f76263ad488a2c6975193235d01215ed7824a71.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/4/f47dc29f5baf5981d50edaeab50ec90da7af24bc.png)

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 25, 2022, 4:53am UTC](https://community.glideapps.com/t/math-date-function-use/37610/7 "2022-01-25T04:53:48Z")

</div>

> [@Uzo](#):
>
> convert all columns to text first

By using a template column? Because I would have thought using a text function like “lowercase” and “trim whitespace” would have converted it to text. No?

---

<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:** [January 25, 2022, 4:55am UTC](https://community.glideapps.com/t/math-date-function-use/37610/8 "2022-01-25T04:55:32Z")

</div>

yes, the template is a good way to do that… just add an empty space before or after… for all values that gonna be used in filters… this way all of them will be in the same format…  
Glide is not working like Google Sheets… each format has an identifier that affects filters.

---

<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 25, 2022, 6:04am UTC](https://community.glideapps.com/t/math-date-function-use/37610/9 "2022-01-25T06:04:53Z")

</div>

> [@David\_Gabler](#):
>
> except that when I have “universal” values, that I may want to use against other tables, my tendency is to put them in a central location --in this case the “user” table,

ah, yes. That makes perfect sense, and I do exactly the same thing. In fact, in most of my apps I will have a whole series of now-based math columns in my user profiles table, that are used as a single reference point. Things like “this year”, “last year”, “first day of this week”, “first day of this month”, etc, etc…

 ![Screen Shot 2022-01-25 at 1.37.08 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/3/c31f6d72699c91a9c0c755f74f5eb52a224af4af.png)

I find this to be a good approach, and avoids a lot of unnecessary duplication.

When it comes to building relations based on dates, I find that the most important thing (as @Uzo pointed out) is to ensure that I’m using text based representations of the dates. So in almost all cases, the two columns I use to form the relation will both be template columns.

My general approach is:

- Use math columns to extract the component parts that I need. For your use case, this would be `Day(Date)` and `Month(Date)` respectively
- If necessary, convert numeric values to their text equivalents. For example, `Month(Date)` returns a number, so if you want the month name that requires some extra massaging (see below).
- Use a template column to stitch the component parts back together.

For converting things like `Month(Date)` and `Weekday(Date)` into text representations, there are a couple of approaches. What some people do is use if-then-else columns: if 1, then Jan, if 2 then Feb, if 3 then Mar, etc. I don’t do this, because it’s way too much effort for my liking - and I’m lazy 😉

What I do instead is create a Lookup table somewhere in my app that has columns that list the month and weekday names…

 ![Screen Shot 2022-01-25 at 1.49.10 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/6/e6cb4db9b4f44359f2a86d9d6eb972b7fef1abf3.png)

And then I use single value columns to obtain the appropriate month or weekday name based on the output of the math column.

So for example, to get the current date into the format you are using, I’d have 4 columns:

- Math column to get the month number (-1, because single value columns use zero based indexes)
- Math column to get the day number
- Single Value column to convert the month number to the month name
- Template column to join the day number and month name

 ![Screen Shot 2022-01-25 at 1.57.27 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/f/cf89e34990564540957f5da4ba3d1d65f6fc46ae.png)

It should be noted that the above can (in theory) be done using a single column with the [Format Date](https://www.glideapps.com/plugins/format-date) plugin. BUT… I have found that plugin to be buggy and unreliable. So I don’t use it, and I don’t recommend using it.

Anyway, take all the above as you wish. Feel free to use any of it, or all of it, or none of it 🙂

---

<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:** [January 25, 2022, 6:07am UTC](https://community.glideapps.com/t/math-date-function-use/37610/10 "2022-01-25T06:07:52Z")

</div>

@Darren_Murphy wow! are you writing a book? 😉

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 25, 2022, 3:48pm UTC](https://community.glideapps.com/t/math-date-function-use/37610/11 "2022-01-25T15:48:29Z")

</div>

> [@Darren\_Murphy](#):
>
> Feel free to use any of it, or all of it

Thank you so much! I have begun to implement this _all_.  
Thank you to everyone who contributed to this topic.

I have to confess I program in a language in which data _type_ is not such a big deal, because if we reference a numeric and a character array in an expression, the program @ runtime does the internal conversions necessary for it to work.

---

<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 25, 2022, 3:56pm UTC](https://community.glideapps.com/t/math-date-function-use/37610/12 "2022-01-25T15:56:28Z")

</div>

> [@David\_Gabler](#):
>
> I have to confess I program in a language in which data _type_ is not such a big deal, because if we reference a numeric and a character array in an expression, the program @ runtime does the internal conversions necessary for it to work.

Sounds like [Perl](https://www.tutorialspoint.com/perl/perl_data_types.htm) 😉

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 25, 2022, 4:21pm UTC](https://community.glideapps.com/t/math-date-function-use/37610/13 "2022-01-25T16:21:49Z")

</div>

Not Perl – Sunbelt’s Visual PL/B (a derivative of Datapoint’s Databus, which was a derivative of COBOL). It’s become a fully modern language, with .NET, etc. But it is a bit obscure (as in no one has ever heard of it).

---

<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 25, 2022, 6:33pm UTC](https://community.glideapps.com/t/math-date-function-use/37610/14 "2022-01-25T18:33:23Z")

</div>

RPGLE and .NET are my bread and butter by day. Glide is my escape by night.

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 25, 2022, 7:06pm UTC](https://community.glideapps.com/t/math-date-function-use/37610/15 "2022-01-25T19:06:37Z")

</div>

> [@Jeff\_Hager](#):
>
> RPGLE

Have not heard that name in a LONG time! 🙂

---

<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 25, 2022, 8:13pm UTC](https://community.glideapps.com/t/math-date-function-use/37610/16 "2022-01-25T20:13:29Z")

</div>

It’s still alive and kicking. The green screen as well. Hard to find programmers that know it these days.

---

<div class="post-metadata">

**Author:** ![David\_Gabler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/david_gabler/32/44332_2.png) [@David\_Gabler](https://community.glideapps.com/u/David_Gabler)\
**Post date:** [January 25, 2022, 8:40pm UTC](https://community.glideapps.com/t/math-date-function-use/37610/17 "2022-01-25T20:40:00Z")

</div>

Same with PL/B. Years ago I worked alongside an RPG programmer – I wrote the MS-Dos character-based screens and her job was to make the RPG programs work the exact same way as mine (tabbing and all). She was in a constant state of frustration (LOL) because RPG and DOS handle keyboard input in different ways (at least in those days).

---

<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 25, 2022, 10:15pm UTC](https://community.glideapps.com/t/math-date-function-use/37610/18 "2022-01-25T22:15:30Z")

</div>

Hehe, yeah it’s different, but I enjoy it. Been doing it for over 20 years. There’s pluses and minuses, but for me it’s a lot easier to work with compared to web development.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [January 26, 2022, 10:16pm UTC](https://community.glideapps.com/t/math-date-function-use/37610/19 "2022-01-26T22:16:04Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
