Skip to main content
Solved

How to convert Day name to weekday number?

  • May 31, 2022
  • 2 replies
  • 74 views

Forum|alt.badge.img+6

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.

Best answer by TheTimeSavingCo

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
)

2 replies

TheTimeSavingCo
Forum|alt.badge.img+31
  • Brainy
  • 6463 replies
  • Answer
  • May 31, 2022

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
)


Forum|alt.badge.img+6
  • Author
  • Known Participant
  • 10 replies
  • May 31, 2022

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
)


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.