Alteryx Designer Desktop Discussions

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

Last Tuesday of the month

rishabhgupta36
7 - Meteor

Hi,

How do we find the last tuesday of the month based upon the input date.

example: input -> 08/02/2024

output-> 08/27/2024

4 REPLIES 4
Qiu
21 - Polaris
21 - Polaris

@rishabhgupta36 
We can use the DateTImeTrim to get the last day of the Month, then determine which week day of it in Number

after than, subtract the difference between the week day of last day and Tuesday from last day.

0808-rishabhgupta36.png

Yoshiro_Fujimori
15 - Aurora

Hi @Qiu ,

Your workflow looks great, but the last expression may not work when the last day of the month is Monday ([WeekdayOfLast] = 1).

lastTuesday_output.png

 

To deal with this case, it may be better to use Mod() as below.

LastTuesday2 = DateTimeAdd([LastDayofMonth],-Mod([WeekdayofLast] + 5, 7),"Days")

Qiu
21 - Polaris
21 - Polaris

@Yoshiro_Fujimori 
Good catch.
Thank you very much.

rishabhgupta36
7 - Meteor

Thanks @Yoshiro_Fujimori @Qiu for your help.

Labels