Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

How to convert Day name to weekday number?

Solved
Jump to Solution
469 2
cancel
Showing results for 
Search instead for 
Did you mean: 

I have a column named Day name which is a single select field containing names of day - Monday, Tuesday, etc.
How can I create another column which gives the weekday number of this? I know I need to use Weekday() function, but how can I set it up such that it converts the string to work with Weekday() function?

Thanks.

1 Solution

Accepted Solutions

Hi Mayank, I don’t think the weekday() function works for that as it expects a date

This formula should serve your needs, and you can modify the numbers as needed depending on when your week starts:

SWITCH(
  Name,
  'Sunday', 0,
  'Monday', 1,
  'Tuesday', 2,
  'Wednesday', 3,
  'Thursday', 4,
  'Friday', 5,
  'Saturday', 6
)

Screenshot 2022-05-31 at 6.47.46 PM

See Solution in Thread

2 Replies 2

Hi Mayank, I don’t think the weekday() function works for that as it expects a date

This formula should serve your needs, and you can modify the numbers as needed depending on when your week starts:

SWITCH(
  Name,
  'Sunday', 0,
  'Monday', 1,
  'Tuesday', 2,
  'Wednesday', 3,
  'Thursday', 4,
  'Friday', 5,
  'Saturday', 6
)

Screenshot 2022-05-31 at 6.47.46 PM

Thank you so much Adam!
Particularly thanks for taking the pain to write the entire function for me when you could’ve simply guided me :grinning_face_with_big_eyes:

Sincerely appreciate your effort. I will start using this.