Number of weekdays and weekend days between 2 dates

24 posts / 0 new
Last post
ravisdxb
Offline
Joined: 01/13/2019 - 06:12

@borderraux: I included the strings "nn weekdays, nn weekend days" since you asked for it in your original post. However, you are able to modify the code and get the results you want. Good job. It is an interesting learning process.
 
By the way, the Python code returns 4,0 but your data shows 3 and 0.. This may be due to including/excuding both the dates in the calcuation instead of the gap between the 2 dates. You need to determine which logic is applicable for your specific requirement.
 
Regards,
Ravi

borderraux
Offline
Joined: 10/22/2018 - 08:39

@ravisdxb , thank you ravi - i am completely new to Python programming (only used VBA in the past and IDEA scripting for the last 6m) so it will be a learning curve to accomodate Python potential into IDEA but taking into consideration how much you can achieve by incorporating python script into IDEA this is a way to go. I have started some online course on panda python as the library offers great options for data munging and cleansing so hopefully at some point in the future i will be able to write some functions in Python to be used in IDEA.
with regards to my data: yes , you are correct that my data shows 3 and 0 - this is the calculation I have done in Excel before exporting the file in to IDEA - I am dealing with hotel booking data hence the difference in my analysis and the results generated by your function (the python function takes into consideration each day within range of dates - start data, end date and all between while for my analysis I need only the night booked by the guests hence the difference).
Thank you for your help.

ravisdxb
Offline
Joined: 01/13/2019 - 06:12

@borderraux: All the best on your journey with Python.
 
If you need 3,0 instead of 4,0 as the result, you just need to modify the code as below:
From: xdays=(xtodate-xfromdate).days+1
To: xdays=(xtodate-xfromdate).days
 
Cheers
Ravi

Pages