Alteryx Designer Desktop Discussions

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

Days Difference between 2 dates excluding Weekends (Sat & Sun)

itsmeanuj
7 - Meteor

Hi,

 

I have a huge dataset where I want to calculate the difference between 2 dates including only Business days (i.e. I just need to exclude weekends). Below is the sample data with the expected output. Data is in the DD-MM-YYYY Format.

 

First DateShipment DateDifference (Expected Output
10-06-202012-06-20202
03-08-202007-08-20204
28-08-202028-08-20200
07-10-202113-10-20214
09-07-202009-07-20200
09-07-202016-07-20205
10 REPLIES 10
BrandonKO
Alteryx
Alteryx
Felipe_Ribeir0
16 - Nebula

Hi @itsmeanuj 

 

One way of doing this

Felipe_Ribeir0_0-1672246793788.png

 

KSowers
Alteryx
Alteryx

Hello, Here is workflow that should work for this example! Let me know if you need anything else!

ShankerV
17 - Castor

Hi @itsmeanuj 

 

Please find the below expected result.

 

ShankerV_0-1672247165219.png

 

Note: The workflow used to achieve the solution is attached which can be downloaded to see how the solution works.

 

If you believe your problem has been resolved. Please mark helpful answers as a solution so that future users with the same problem can find them more easily!!!!

 

Many thanks

Shanker V

ShankerV
17 - Castor

Hi @itsmeanuj 

 

There will a difference in your desired output and mine as because I think you have ignored to eliminate the weekends for the below dates. It should be 0 and 2 respectively.

 

ShankerV_0-1672247310259.png

ShankerV_2-1672247621636.png

 

 

ShankerV_1-1672247561163.png

 

Please let me know if you need your logic to be revisited. So can do the needful.

 

Many thanks

Shanker V

itsmeanuj
7 - Meteor

Hi all,

 

Thanks for your response on this problem. But the suggested solution includes multiplying rows in the process which is not feasible for my data. My data includes millions of records already. We also need to consider that if any of the 2 dates fall on a weekend then we should exclude that as well. please see the example below  

 

First DateShipment DateDifference (Expected Output
17-10-202124-10-20215
ShankerV
17 - Castor

Hi @itsmeanuj 

 

Addressing the issue 1:

 

Please find my revised workflow to share the solution for the recent issue raised.

 

ShankerV_0-1672255029097.png

For both the dates I have tested and working fine. 

17-10-2021 Sunday

16-10-2021 Saturday

 

ShankerV_1-1672255052569.png

 

Many thanks

Shanker V

ShankerV
17 - Castor

Hi @itsmeanuj 

 

Addressing the issue 2:

 

I don't think we have any other way to reach your solution except using Generate Rows.

 

To overcome the issue, I can suggest you to filter the records into parts less than millions and run the workflow.

or

Using the macro. 

ShankerV_0-1672255653219.png

ShankerV_1-1672255666530.png

 

As I do not know whether you are connected to a database and updating the output directly to database or working from excel or any other source. Hence that decision needs to be made in real time.

 

Many thanks

Shanker V

RogerS
Alteryx
Alteryx

I developed a network days macros that does this.  You can also pass in a list of Holidays to remove in addition.  I attached the macro and a link to an  additional macro that pulls federal holidays.  If this helps, please accept as a solution and star the below macro post.  Thx!

 

https://community.alteryx.com/t5/Community-Gallery/US-Federal-Holidays/ta-p/1055939

Labels