Calculating The Number Of Days Between Dates
Forums
Hi Brian
I trust that you are well? I am trying to calculate the number of days between two dates (inclusive). I have used @age and this works fine. However is there a way to exclude Saturday and Sunday from the calculation? Also I need to exclude certain public holidays as well. Is this possible through a custom script or function? I would like to input the public hoilday dates or I can even code them in. I am using IDEA v8.5.
Thank you in advance!
Regards
Aveen
weekday_dif
Hi Aveen, here is a custom function that will calculate the number of work days (excluding Saturday and Sunday) between two dates. Something with adding in holidays is more complex and would probably have to be done through a script. I am not sure if I have time to do something like this right now but if I find some time I will put something together. So test this out and let me know if you find any problems with it, I did a quick test so it should work but please do some testing on it yourself before relying on it.
Hi Brian,
Hi Brian,
Thanks for your blog. It's quite interesting. I am looking for a way to incorporate Holidays in my data to carry out tests like people posted transactions on Holidays. Is it possible to do this in IDEA? Or if you have created any Custom Script for this, please share.
Hi sbarnway and welcome to
Hi sbarnway and welcome to the site. Yes it is possible and that is a common test. You might want to check out my date extraction script and see if it does what you are looking for. http://ideascripting.com/ideascript/date-extraction
You could also do this with a
You could also do this with a saved equation like:
@match(date,"20190101","20190218","20190419")
You would list all the holidays for the year and extract the matches to a new file thereby creating you transactions on holidays subest of your data. By saving the equation you can reuse it the next year by opening it up and using the find/replace feature in the equation editor to change 2019 to 2020. You would then change any dates where a holiday floats to different dates in a given year.
Hi Aveen,
Hi Aveen,
Yes things are good, I am enjoying that the site is starting to have more posts, that is enjoyable that more people are starting to use it.
You could definitely create a script to do this but I am thinking of a custom function, I will just have to think about how to add the public holidays so that they are excluded. Let me think about this and see what I can come up with.