I have fields holds day name like "Saturday" or "Wednesday".. etc
I need to convert it to day number, so "Saturday" becomes 6 and Wednesday becomes 3.. etc
I was able to do the opposite, convert day number to day name, but not the vice versa.
what would you suggest ?
Hi @b_sab
The easiest and straight forward way would be to write an If else condition block. Like below
IF [Date Weekday]="Sunday" THEN 7
ELSEIF [Date Weekday]="Monday" THEN 1
ELSEIF [Date Weekday]="Tuesday" THEN 2
ELSEIF [Date Weekday]="Wednesday" THEN 3
ELSEIF [Date Weekday]="Thursday" THEN 4
ELSEIF [Date Weekday]="Friday" THEN 5
ELSEIF [Date Weekday]="Saturday" THEN 6
ELSE Null() ENDIF
DateTimeParse doesnt seem to work on weekdays to convert to date and back to week number.
Hope this helps 🙂
@b_sab
Tried a another approach without conditional statement.
The proposed solutions work great, for all your future data-related tasks you can download the Abacus for some more flexibility - https://community.alteryx.com/t5/Engine-Works/An-Overview-of-the-Alteryx-Abacus-Add-In/ba-p/398982
Thanks. the problem is i have the values in fields and not planning to create new rows. was looking if there is a formula to do that. might need to stick with IF ELSE solution
Hi @b_sab
Even i looked it to check is there a way Wednesday can be converted to a date and then a week day number.
Using DateTimeParse but seems like only DateTimeFormat can handle weekdays but DateTimeParse doesnt handle weekdays. Apparently
Hi @b_sab
Very similar to @atcodedog05's if/else statement, but I managed with a switch/case, which I personally much prefer for use-cases like this as I find them cleaner, but result is the same:
Hope this helps!