Skip to main content

Calculating The Number Of Days Between Dates

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
 
 

Brian Element Thu, 02/20/2014 - 09:43

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.

Brian Element Thu, 02/20/2014 - 12:55

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.

weedkay_dif.ideafunc

aveenm293 Fri, 02/21/2014 - 03:26

In reply to by Brian Element

Hi Brian
Thank you very much. I will give it a go. I am also testing something out. Also I can't seem to download the function. Can you please check it was uploaded correctly.
Thank yoou
Regards
Aveen
 

Brian Element Fri, 02/21/2014 - 07:20

Hi Aveen, that is really strange.  I can download it at work on a older browser but it didn't like it at home.  I have attached it again in a different way, let me know if you can and if not I will try zipping it up and seeing if that works.

Brian Element Sat, 02/22/2014 - 07:40

Interesting, yesterday I couldn't save it on this browser and this morning I can, compuers.  Glad you are able to get it.

sbarnwal Thu, 03/05/2020 - 02:23

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.
 

Steven Luciani Thu, 03/05/2020 - 08:48

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.

 

 

 

 

dianir Wed, 06/03/2020 - 05:13

Hi, did this matter solved yet?
because i have same problem to calculate date difference excluding public holiday.
anyone can help, please?
thank you before..