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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateDiff ("D") Not calculating weekdays only

Status
Not open for further replies.

Hfnet

IS-IT--Management
Dec 31, 2003
369
GB
I am using a GetDate Module to calculate working days because DateDiff("D", xxx, xxx, 2) is calculating every day including weekends, howver this is slowing down the query time due to the amount of records processed.

How can I use DateDiff in a query to return weekdays only?

Ask not what you can do for your boss, ask how much it's worth.
 
Apologies, I meant to use DateDiff("W", xxx, xxx, 2), NOT "D"

It still does not return weekdays even though ms Access Help indicates that "W" whould return weekdays

Ask not what you can do for your boss, ask how much it's worth.
 
Yes, I have been using a similar module to get my dates, but it slows the query down dramatically when I am processing thousands of records.

What I wanted was a native way of calculating weekdays (holiday days not important)

Ask not what you can do for your boss, ask how much it's worth.
 
Reading this Microsoft article ACC: "W" Option of the DateDiff() Function Does Not Work, shed some light on why "W" doesn't work as one might expect. There's also a workaround function in the link, which doesn't exclude extra holidays, so it might be more efficient than the one you're using (though I haven't tried).

I think that's the options you have
* tweak/optimize your custom function
* tweak/optimize your query

- there might of course be other alternatives too ...

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top