Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counting days in a weekday dependant formula 1

Status
Not open for further replies.
Aug 24, 2005
56
US
Hello,

I currently have a Query that calculates the number of days that an order is late using

Now()-[tableX].[DateX]

The problem with this is that the number returned is the count of calendar days and not business days. Is there a way to count only business days (Mon-Fri)?

Thanks,

Cordeiro82
 
Yes. Search this forum for 'business days' or look in the faq section for a method including holidays. Post back if you have a more specific question on the method(s) that you find.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Or a relatively simple solution that doesn't involve looping or modules (but does not account for holidays):
Code:
(datediff("w",[start date], [end date]) * 5) + 
(datediff("d",[start date], [end date])) mod 7 + 
((datepart("w", [start date]) < datepart("w", [end date])) * 2)
The first line calculates the number of full weeks and multiplies by 5
The second line gives the number of days left in a partial week
The third line subtracts 2 (accounting for the weekends) if the partial week spans a weekend.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
You need to make sure you use a DateDiff parameter to count Monday as the first day of the week.
The correct formula should actually look like this:

Code:
=(DateDiff("d",[start date],[end date],2))-((DateDiff("w",[start date],[end date],2))*2)

As Traingamer states this will not account for holidays but it will give users a count that is generally accurate which, is good enough for my needs. Hope this helps.
 
Hello this is what I need too, but how can I get it to count the amount of business days elasped in a given month counting back for that date field only excluding weekends and possibly holidays?

Example:
mydatefield busDays
02/27/2008 18 days
01/18/2008 13 days
 
Did you read the FAQ ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top