Calculating The Number Of Days Between Dates

12 posts / 0 new
Last post
aveenm293
Offline
Joined: 10/23/2012 - 16:02
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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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
Offline
Joined: 10/23/2012 - 16:02

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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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.

aveenm293
Offline
Joined: 10/23/2012 - 16:02

Hi Brian
I have managed to download the function.
Regards
 
 

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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

sbarnwal's picture
sbarnwal
Offline
Joined: 03/05/2020 - 01:02

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.
 

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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

Steven Luciani
Offline
Joined: 07/31/2012 - 13:20

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
Offline
Joined: 06/03/2020 - 04:38

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..

Pages