449,024 Members | 932 Online
Need help? Post your question and get tips & solutions from a community of 449,024 IT Pros & Developers. It's quick & easy.

# I need help with calculating business days

 P: n/a I am working in vb2005. how can I calculate business days (not including holidays and weekends) between 2 dates? thanks Al Jun 27 '08 #1
8 Replies

 P: n/a On Apr 15, 10:28*am, Al

 P: n/a not sure but this Weeks = Fix(CDec(DateDiff(DateInterval.Day, tDate, Date2)) / CDec(7)) complains about a decimical to long conversion and when I do Weeks = cint(Fix(CDec(DateDiff(DateInterval.Day, tDate, Date2)) / CDec(7))) the calcuation is not correct? "Martin H." I am working in vb2005. how can I calculate business days (not includingholidays and weekends) between 2 dates? thanksAl Jun 27 '08 #4

 P: n/a Hello Brian, I usually have the option "Strict" set to "Off" while your's is set to "On"... Weeks = CLng(Fix(CDec(DateDiff(DateInterval.Day, tDate, Date2)) / CDec(7))) Should do the trick (since "Weeks" is a Long variable, you need to use CLng). Best regards, Martin On Apr 16, 6:48 am, "Brian S."

 P: n/a Thnks to every one. I will try this and get back "Al" wrote: I am working in vb2005. how can I calculate business days (not including holidays and weekends) between 2 dates? thanks Al Jun 27 '08 #6

 P: n/a On Apr 16, 9:40*am, Al

 P: n/a What advantage do you have over having this option set to "Off". just curious.. i'll look it up later though.. just wanted your opinion. "HKSHK" not sure but this Weeks = Fix(CDec(DateDiff(DateInterval.Day, tDate,Date2)) / CDec(7)) complains about a decimical to long conversion and when I do Weeks =cint(Fix(CDec(DateDiff(DateInterval.Day, tDate, Date2)) / CDec(7))) thecalcuation is not correct?"Martin H."

 P: n/a Hello Brian, One advantage is that you don't have to convert data types into each other (it's like in the old VB6 days) as VB will do that for you. Best regards, Martin Am 17.04.2008 05:23, schrieb Brian S.: What advantage do you have over having this option set to "Off". just curious.. i'll look it up later though.. just wanted your opinion. "HKSHK" Hello Brian,I usually have the option "Strict" set to "Off" while your's is set to"On"...Weeks = CLng(Fix(CDec(DateDiff(DateInterval.Day, tDate, Date2)) /CDec(7)))Should do the trick (since "Weeks" is a Long variable, you need to useCLng).Best regards,MartinOn Apr 16, 6:48 am, "Brian S." >not sure but this Weeks = Fix(CDec(DateDiff(DateInterval.Day, tDate,Date2)) / CDec(7)) complains about a decimical to long conversion and when I do Weeks =cint(Fix(CDec(DateDiff(DateInterval.Day, tDate, Date2)) / CDec(7))) thecalcuation is not correct?"Martin H."

### This discussion thread is closed

Replies have been disabled for this discussion.