Forum Discussion

kumar25's avatar
kumar25
New Contributor II
2 years ago

Difference between 2 dates, excluding weekends

I have 2 date values, have to find the difference between both of them. Weekends to be excluded.

I am using the below expression to derive the value.

parseInt((Date.parse($Date2.toString())-Date.parse($Date1.toString()))/(1000*60*60*24)*0.71)

This logic is failing when

1. Date1 and Date2 are in the same week(for example 15/01/2024 and 19/01/2024)

2. Date 1 and Date2 are in different weeks but the difference is less than 7 days(19/01/2024 and 24/01/2024)

2 Replies

  • Hello kumar25.

    Attached below is a sample pipeline that you can use.

     

    In general, as a short explanation, I was following the steps below:

    1. Calculate Days Diff between the Start and End Date.
    2. Generate all days in that interval.
    3. Filter out the weekends.
    4. Count the remaining days.

    Let me know if you have any questions and if this helps you.

    Regards,

    Aleksandar.