Extracting the "day of the week" from the date

Hi fellow gliders,

If I have a known date and you display it in the long format, you are given the day of the week as well. Is it possible to display on the day of the week and not any other information e.g. display only “Monday” or “Tuesday”.
This I would want to use to relate to another table if possible…
Thanks

Use WEEKDAY(date) in a math column. You can use the resulting number for your relation, or use an IF column to convert the number to the day name.

1 Like

Thank you @Jeff_Hager
You are a :star2:

1 Like

I get numbers e.g. 2/5/10…

Any idea how I convert this to actual days e.g. Monday/Tuesday

Use it in a template

1 Like

How do you get 10 as a result? There are only 7 days in a week, so at most you should only have 7. Use an IF column to convert the number to the day.

IF 1 THEN Sunday
ELSEIF 2 THEN Monday
etc.

1 Like

I am a practical type of learner.
Let’s use 09/06/2021 for example and then you can explain from there because when I use the math column, I get the number ‘6’ as answer…

What formula are you using. Seems like you may be using DAY(date). It should be WEEKDAY(date).

Edit: How do you read dates? Is that September 6th, or June 9th?

Ahhhh…Sorry, I had a “blonde” moment there for a minute. I wrote “day” instead of “WEEKDAY”…
Let me get to it …

Thanks Jeff

1 Like

It’s 6 September. But my issue was as explained in my previous response…

1 Like

Just thinking about @Uzo’s suggestion to use a template. That may actually be a little more efficient compared to an IF column. Point the template column template setting to the math column. Then create replacement values for each day. @Darren_Murphy has used a different method of a separate table to store each day in a row, then use a single value column to use the weekday number as an index to select the correct day row in the separate table. It’s useful if you have to check the weekday several times in you app. If it’s only once or twice, then it’s just easier to use the IF column or TEMPLATE column to convert the number to the day.

2 Likes

yep, and that’s what led me to the single value lookup solution. It became tedious (and error-prone) to keep re-defining that ugly if-then-else column over and over again…

1 Like

My 2 cents to make simpler this solution using Hell Yes-Code:

let d = new Date();
const week = ["Sunday","Monday","Tuesday","Wendesday","Thursday","Friday","Saturday”];

return week[d.getDay()]

Saludos!

4 Likes

Donde pones el código para calcular el día?.. Template?..Math?.. y donde pones la fecha a calcular?

Where do you use this code to calculate the day?
Template?. Math?.. and where do you insert the date to be calculated from?

Gracias,

MGarza

If you’re talking about @gvalero’s code, use the link below in your Experimental Code. I adapted it to my Replit.

https://get-weekday-from-time.thinhdinh.repl.co

3 Likes

Hola,

Your plan B if you don’t want to use the Thind’s plugin is to work with Glide’s JavaScript pluging

https://column.sh/hell-yes-code

Saludos

2 Likes

You should not use JavaScript for this. Use the Format Date column, with format cccc:

7 Likes

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