Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Dynamic Retrival Date

grail0305
6 - Meteoroid

For example the input Date is July 15, 2025 how can I create a formula that will get the previous Sunday and Monday of the given Date:

Input : July 15, 2025

Output:

Previous Sunday: July 13, 2025

Previous Monday: July 7, 2025

 

can you anyone help using the formula tool 

 

thanks in advance

4 REPLIES 4
binuacs
21 - Polaris

@grail0305 

 

prev Sunday:

 

DateTimeAdd([InputDate], -ToNumber(DateTimeFormat([InputDate], "%w")), "days")

Prev Monday:

DateTimeAdd([InputDate], -(
IIF(ToNumber(DateTimeFormat([InputDate], "%w")) = 0,
6,
ToNumber(DateTimeFormat([InputDate], "%w")) - 1)
), "days")

 

grail0305
6 - Meteoroid

@binuacs Thanks the formula for sunday is ok, but on the prev monay there is an issue, with regards to the parenthesis;

grail0305_0-1752575347792.png

 

aatalai
15 - Aurora

@grail0305 you could try this previous monday

DateTimeAdd([Date],

Switch(DateTimeFormat([Date],"%A"),Null(),"Monday",-7, "Tuesday",-8,"Wednesday",-9,"Thursday",-10,"Friday",-11,"Saturday",12,"Sunday",-12),

"day")

 

 

 

 

 

previous sunday

 

DateTimeAdd([Date],

Switch(DateTimeFormat([Date],"%A"),Null(),"Monday",-7, "Tuesday",-8,"Wednesday",-9,"Thursday",-10,"Friday",-11,"Saturday",-12,"Sunday",-13),

"day")

 

previous sunday

 

 

 

binuacs
21 - Polaris

@grail0305 You missed the datetime add part

 

DateTimeAdd([InputDate], -(
IIF(ToNumber(DateTimeFormat([InputDate], "%w")) = 0,
6,
ToNumber(DateTimeFormat([InputDate], "%w")) - 1)
), "days")

Labels
Top Solution Authors