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

Exclude Saturday and Sunday at Runtime every week from the workflow

rahulshetty925
8 - Asteroid

Hi All,

 

I have been using [Date] = DateTimeParse(DateTimeToday(),"%Y-%m-%d") in a filter for today's date and I have been using [Date] = ToDate(DateTimeAdd(DateTimeToday(), 1, "days")) for tomorrow's date in a filter for tomorrow's date data.Both are working fine for respective workflows.

 

Now is there any technique to exclude Saturday and Sunday every week and move ahead at runtime for both these workflows.

For example - for tomorrows date I can go in and make it 2 or 3 manually, that works [Date] = ToDate(DateTimeAdd(DateTimeToday(), 3, "days")).But I'm looking for some dynamic or automatic way.Thank You.

 

Regards,

Rahul

5 REPLIES 5
DavidP
17 - Castor
17 - Castor

You can create a new field with the following formula: 

 

DateTimeFormat([Date],"%a")

 

Then use a filter tool with the following condition:

 

[dayofweek] NOT IN ('Sat', 'Sun')

 

See workflow attached

rahulshetty925
8 - Asteroid

Hi David,

 

My data doesn't have sat or sun.For example by using this DateTimeFormat([Date],"%a").The output is Fri Mon Tue Wed Thur Fri.

 

So there is no point of using [dayofweek] NOT IN ('Sat', 'Sun') in my case.What I need is dynamically replace this formula [Date] = ToDate(DateTimeAdd(DateTimeToday(), 1, "days")).

 

Example - If I run my workflow for tomorrow's date using Date = ToDate(DateTimeAdd(DateTimeToday(), 1, "days"))  I get blank 0 columns for today as there is no data for Saturday.

I just need some tweak in the formula which would directly show Monday's data dynamically and not enter 1 2 3 4 manually every time.

 

Thanks for the help.Much appreciated.

 

Rahul

jasperlch
12 - Quasar
Hi, you could first create a new int16 field called daystoadd:
if DateTimeFormat(DateTimeToday(),"%a") = 'Fri' then 3
elseif DateTimeFormat(DateTimeToday(),"%a") = 'Sat' then 2
else 1 endif

Then create a filter:
[Date] = ToDate(DateTimeAdd(DateTimeToday(), daystoadd, "days")).
rahulshetty925
8 - Asteroid

That worked.

Thanks Jasperich.

 

rahulshetty925
8 - Asteroid

Hi jasperich,

 

A quick question, Based on the same question.My workflow runs fine now for today and tomorrow.

 

But in case of a holiday, the workflow fails as Friday+3 would be Monday and Monday was a public holiday yesterday.

 

I have a holiday excel file but was not sure how do I include it in the existing logic built.

 

All the solutions I saw online has a range of date or input has all the dates in which case join works.

 

But in my case the input date doesn't have any public holiday in it or weekend as it was in the previous solution that you provided.Thanks.

 

Regards,

Rahul

Labels