Alteryx Designer Desktop Discussions

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

Get the weekday

Su
7 - Meteor

Hi ,

 

Is there a simple way to get the fist day of the week given a date? 

For example, 2016-08-31 would be the input date and the output that I'm looking for would be: 2016-08-29.

 

Thanks in advance.

Susana

 

5 REPLIES 5
jdunkerley79
ACE Emeritus
ACE Emeritus

Try something like: 

DatetimeAdd([date],mod(DateTimeDiff("2016-01-04",[date],"days"),7),"days")

 

This works out difference from a known Monday and then applies day shift mod 7

AdamR_AYX
Alteryx Alumni (Retired)

Mine was similar

 

DateTimeAdd([Field1],-Mod(ToNumber(DateTimeFormat([Field1],"%w"))+6, 7),"days")

@jdunkerley79 Does yours work for dates both sides of your chosen Monday?

Adam Riley
https://www.linkedin.com/in/adriley/
jdunkerley79
ACE Emeritus
ACE Emeritus

@AdamR_AYX probably not, could easily replace with 1900-01-02.

 

The %w is not documented - http://downloads.alteryx.com/Alteryx8.6.2/WebHelp/Reference/DateTimeFunctions.htm, been hacking round that one with my own addins for ages!

 

Always nice to learn a new trick

Su
7 - Meteor

Thanks a lot guys ! 

KrisV
Alteryx Alumni (Retired)

Hi @jdunkerley79, please see our revised Date/Time Functions help page in the current release of the online help. You'll see that %w is now documented under the Format Specifiers, Separators, and Examples section.

 

If you have any feedback on this help page, please send it our way at helpfeedback@alteryx.com. Thanks!

 

-Kris Vickland

Technical Writer

Labels