Number of working days between two dates excel 2010

number of working days between two dates excel 2010

It's a simple task to use SAS to compute the number of weekdays between two dates. You can use the INTCK function with the WEEKDAY interval to come up with that number. If you want to compute the number of working days between two dates, and assuming that every weekday is also a workday, this is perfect. However, most cultures observe certain non-productive days that they call "holidays", and this use of the INTCK function does not consider these when discounting the total sum of days.

This type of function is useful for project planners when they want to tick down the number of remaining days available to complete some work task. While there is no direct analogy to that function in SAS, it's not difficult to write your own functions by using the FCMP procedure.

Here is an example of this function:. This function can read a range of holiday dates from a data set. This shows an example of the result:.

If you want to see the complete example with sample holiday data, I've placed it on the support site here. Special thanks to my colleague Jason, whose paper I referred to , for his help in refining this example. He's also co-author of the popular SAS for Dummies book, author of Custom Tasks for SAS Enterprise Guide using Microsoft. NET , and a frequent participant on the SAS Enterprise Guide discussion forum. Thanks for the how-to on the solution for Excel's "networkdays", and on doing custom functions.

Thanks Jason and Chris. I use "intkc" in a weekly report to calculate unit sales needed before a deadline. It's a great function. I use SAS 9. And the log gave me this error: Budi, PROC FCMP received lots of enhancements in SAS 9.

If you're comfortable with DATA step, you could re-implement similar logic using hash tables in SAS 9. It wouldn't be as elegant as the function syntax, but it would get the job done. This is a great question for the forums at communities. Try posting in the DATA step forum for a solution Thanks for the suggestion Chris, think I've found the solution using hash object in this link https: Would you please share how you used the hash functions.

I read the article in the link you send, but l did not understand it. Perhaps if you can paste a code, that would be helpful. Patrick, check out this free "SAS Talk" from Michelle Burlew on the Hash object. It should be enough to get you started. I have used your code, but I am finding an anomaly whichI don't understand.

Of records where the start and finish dates are exactly the same, 23 are coded as having 0 workdays and the remainder coded as having 1 workday. The original data included datetime variables, but I used datepart var to extract the date part to allow the code to work. Are you including a Holiday data set as well? Perhaps it has to do with how the holidays fall. Try changing the function use to:.

Here's the test I ran. When the DOW var day of week is 7 or 1, the span is 0. Otherwise it's a weekday, so the span is 1. Yes that works, but if there is a holiday on the Monday for instance in the holiday dataset and start and end dates are on the Tuesday, which is a working day, the code also gives zero. I see the problem! But if the previous day is a holiday, the logic also decrements the difference value.

Calculating working hours between two dates

So we end up with this special "off by 1" condition. Saturday can also be a working day. How can one modify the above function to include satudays as working days?

html - How to calculate the number of days between two dates using JavaScript? - Stack Overflow

Thanks Chris, I tried that but it won't give me the correct days, for instance: Basically, l am calculating the number of days from the 10th of each month to the 10 of the next month, where weekdays plus saturdays are considered as business days. I think I understand now. Perhaps it is better to use the DAY method for INTCK instead, and then go back and subtract all of the SUNDAY occurrences. I need to calculate business hours.

The data is in DATE20 format. I need the limit the business hours to be between 8am and 5pm, exclude weekends and holidays. So basically any time that is not between the hours of Has anyone written that in SAS? Michelle, so you're just trying to "round up" to the next business day, if the timestamp falls outside of the business hours? Yes, I'm sure that someone has done that -- there isn't much that hasn't been done, by someone!

If you post a sample of what you have for data, several records and what you want, I'm sure that you'll get several helpful responses. Do I need to make a system setting change or am I missing something.

number of working days between two dates excel 2010

Did you try running the complete example that I provided? Let me know if the complete example does not work. Hi Chris, I have used your code and it works!!!

However,I have some difficulties to apply it for my work. I need to calculate the working days between two days, which requires to exclude the weekends and holidays.

First, different provinces have different holidays. Could you add one more parameter "province" in the format function?

Second, if one of the holidays falls in the weekend, the consecutive weekday will not be the working day. How to exclude those weekdays? Thank you very much for your help.

number of working days between two dates excel 2010

Business Technology Blog Directory Subscribe. Calculating the number of working days between two dates By Chris Hemedinger on The SAS Dummy May 9, Programming Tips.

Tags custom functions fcmp networkdays SAS programming SAS tips. Reni on May 9, 3: Alan Churchill on May 9, 5: Jared on May 10, Syed Ibrahim on May 11, 9: Lindsey Puryear on June 3, 1: Budi C on June 15, 6: Chris Hemedinger on June 15, 8: Budi C on June 17, Chris Hemedinger on June 18, Budi C on June 18, 9: Patrick on December 4, 5: Chris Hemedinger on December 4, 9: Diane Hindmarsh on December 4, 8: Chris Hemedinger on December 5, 9: Diane, Are you including a Holiday data set as well?

Try changing the function use to: You should get 0 for all weekend days, and 1 for any weekdays.

Count the Days between Two Dates in Excel

Diane Hindmarsh on December 5, Chris Hemedinger on December 6, Thanks for the feedback! Patrick on December 11, 7: Chris Hemedinger on December 11, 9: Patrick on December 13, 3: Chris Hemedinger on December 13, 9: Patrick, I think I understand now.

Count the Days between Two Dates in Excel

Patrick on December 14, 7: Hi Chris, Thanks alot!! Michelle Renick on May 23, Chris Hemedinger on May 23, LD on May 1, Chris Hemedinger on May 7, Thank you very much for your help Reply. Leave A Reply Cancel Reply.

Rating 4,8 stars - 952 reviews
inserted by FC2 system