Skip to main content

Number of weekdays and weekend days between 2 dates

Dear all ,
 
As per subject what is the easier way to find out the exact number of working days and weekend days that occur between 2 dates (regardles of public holidays).
Lets analyse the below example:
Start Date          End Date
02/01/2019        15/01/2019
Equation: End Date - Start Date
Result: 10 working days, 4 weekend days
I know that i could potentially use: @Dow and @Workday functions in IDEA but without counting first the number of days between both dates and then using nested Ifs statements I cannot see it working.
 
Any tips are much appreciated.
 
 
 
 

borderraux Tue, 01/29/2019 - 08:32

This is the version i am using:
Client Version: 10.3.0.1139 (X86 )
However before posting my reply yesterday I tried to run it and it didnt work...
 

borderraux Tue, 01/29/2019 - 11:29

This is the version i am using:
Client Version: 10.3.0.1139 (X86 )
However before posting my reply yesterday I tried to run it and it didnt work...
 

ravisdxb Tue, 01/29/2019 - 13:17

You need to enable an option for running Python within IDEA. Please refer to enclosed image. 
File -> Options -> Run Python Scripts

borderraux Wed, 01/30/2019 - 12:28

Thanks Ravi but that was the first thing i have done - if you try to run Python function without that option checked then IDEA generates explicit error message prompting user to check that boc.
Unfortunately that is not the issue.

Brian Element Wed, 01/30/2019 - 19:33

In reply to by borderraux

Hello borderraux,

This is what I did.  I first downloaded the python custom function and saved it in the Custom Functions.ILB directory under the project I am going to use it.

I changed the extension to .py and removed the .txt portion. 

I then created a character virtual field of length 40.

and entered the following equation.  I am using the Sample-Payments from the Sample project folder.

When I run this equation I get the following:

If you are stil having problems let us know what they are.  I can't remember which language version you are using but in some languages you will have to change the commas "," to semi-colons ";" in the equation editor for field separators.

Brian

borderraux Mon, 02/11/2019 - 07:52

Thank you Brian.
Please see the sequence of the screenshots i have taken while trying to run the function.
As you can see from the attached screenshots today I cannot even see the function being present in Custom Function.ILB folder (that wasnt the case yesterday and day before yesterday)....
 

Brian Element Thu, 01/31/2019 - 08:23

Hello borderraux,

You won't see it as a custom function as it is in python and needs to be called from the @python() function.  Try my @python equation in my previous post with your dates and let me know if it works.  

Brian

borderraux Thu, 01/31/2019 - 08:24

cont.
I am not sure if that matters (or what consequences it might have) but i have noticed that after placing the python function file within the Custom FUnction folder there is another folder created '_pycache_' within about 15 minutes ...

Brian Element Thu, 01/31/2019 - 08:50

In reply to by borderraux

That is normal for python.  In theory because of it your python script should work quicker the next time you run it.

borderraux Thu, 01/31/2019 - 10:11

Thank you Brian, all worked ok - i modified the function slightly to display as a result the numbers of weekdays/weekends rather that the string as well.
 Ravi , thank you for providing the function in first place - it seems that I just didnt realise that Python function can be run by IDEA even if it is not visible physically to the user.

The website encountered an unexpected error. Try again later.