Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Date conversion to Day of Week

BarleyCorn
8 - Asteroid

Trying to convert a date to day of the week. So field of actual date to new variable that is Monday, Tuesday, Wednesday, etc... based on the field date. Have tried DateTimeParse and DateTimeFormat functions in Formula Tool - no luck!

 

This is a basic excel command????

 

Thanks

 

14 REPLIES 14
tz8888
5 - Atom

It worked. Thanks!

kurtwz
8 - Asteroid
DateTimeAdd([DateField],5-ToNumber(DateTimeFormat([DateField],"%w")),"days")

 

This one wins. 🙂 🙂  If you want it to convert to the following Sunday, change the "...5-...' to a "...7-...".

KevinHarrison
8 - Asteroid

You can use a datetime parse tool for this. Date/time to string - Custom - day (must be lower case I believe).

 

KevinHarrison_0-1608000168861.png

 

juanlevinig
5 - Atom

Nice!! Thanks for your support!

MRapp
7 - Meteor

This idea helped me!

For reference purpose, this is the correct syntax for a Saturday Week End Date.

You might want to apply the parse tool to get the HH:MM:SS out of the date as next step.

 

if DateTimeFormat([Invoice
Date],"%a") = "Sat" then DateTimeAdd([Invoice
Date],0,'days')

 

elseif DateTimeFormat([Invoice
Date],"%a") = "Sun" then DateTimeAdd([Invoice
Date],6,'days')

 

elseif DateTimeFormat([Invoice
Date],"%a") = "Mon" then DateTimeAdd([Invoice
Date],5,'days')

 

elseif DateTimeFormat([Invoice
Date],"%a") = "Tue" then DateTimeAdd([Invoice
Date],4,'days')

 

elseif DateTimeFormat([Invoice
Date],"%a") = "Wed" then DateTimeAdd([Invoice
Date],3,'days')


elseif DateTimeFormat([Invoice
Date],"%a") = "Thu" then DateTimeAdd([Invoice
Date],2,'days')


elseif DateTimeFormat([Invoice
Date],"%a") = "Fri" then DateTimeAdd([Invoice
Date],1,'days')
else ''
endif

 

Labels