We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Weekend condition

bubblyjai1982
8 - Asteroid

Hi All

 

Need assistance !!

 

I'm looking to arrive at good business day, for example I have Date column with yesterday date (COB Date) and want to put a condition stating.

 

"If COB date is Saturday or Sunday then it should appear Friday else COB Date"

 

Note: COB date is nothing but yesterday date.

 

Using Formula Tool I have tried this but not able to extract accurate condition.

 

IF DateTimeFormat(DateTimeAdd([COB Date],-1,"days"),"%A") = "Saturday"
THEN
DateTimeAdd([COB Date],-2,"days")
ELSEIF
DateTimeFormat(DateTimeAdd([COB Date],-1,"days"),"%A") = "Sunday"
THEN
DateTimeAdd([COB Date],-2,"days")
ELSE
DateTimeAdd(datetimenow(),-1,"days")
ENDIF

 

Thanks 

3 REPLIES 3
PangHC
13 - Pulsar

@bubblyjai1982 i guess it should not use the datetimenow() where the last part. it cause other yesterday got vary. you should use [COB date] instead.
and if it should keep the date if it not weekend. Ignore the first formula (Option 1 (1/2)). 

Screenshot 2025-08-05 170858.png

binuacs
21 - Polaris

@bubblyjai1982 If COB date is yesterday’s date then you don’t need to -1 days from COB date

IF DateTimeFormat([COB Date],"%A") = "Saturday"
THEN
DateTimeAdd([COB Date],-1,"days")
ELSEIF
DateTimeFormat((COB Date],"%A") = "Sunday"
THEN
DateTimeAdd([COB Date],-2,"days")
ELSE
[COB Date]
ENDIF

davidskaife
14 - Magnetar

Hi @bubblyjai1982 

 

If COB Date is already 'yesterday', why are you taking a further day off it using DateTimeAdd? If all you want to do is if the date is a Saturday or Sunday then move it back to the Friday then try this instead

 

IF DateTimeFormat([Date],"%A") = "Saturday"
THEN
DateTimeAdd([Date],-1,"days")
ELSEIF
DateTimeFormat([Date],"%A") = "Sunday"
THEN
DateTimeAdd([Date],-2,"days")
ELSE
[Date]
ENDIF

 

If this isn't right what's the error/incorrect output you're getting currently, and providing an example input and expected output would be helpful!

 

Labels
Top Solution Authors