PC Review


Reply
Thread Tools Rate Thread

Access Number of Days Query

 
 
Morena
Guest
Posts: n/a
 
      9th Sep 2003
Is there an access query way of counting the number of
working days per month.
I tried to use the function networkdays and workdays but
access did not recognise these function.
Thank in anticipation
 
Reply With Quote
 
 
 
 
John Vinson
Guest
Posts: n/a
 
      9th Sep 2003
On Tue, 9 Sep 2003 01:46:31 -0700, "Morena" <(E-Mail Removed)>
wrote:

>Is there an access query way of counting the number of
>working days per month.


It's not altogether trivial, since different countries and different
companies recognize different holidays! It's not just weekends that
need to be considered; you'll also need a table of the holidays
recognized by your company.

>I tried to use the function networkdays and workdays but
>access did not recognise these function.


Blame Microsoft for this one. These are Excel functions, not Access
functions, and are not available in Access, despite their presence in
the Help index. GRRR!!!

See http://www.mvps.org/access/datetime/date0012.htm for some sample
code to achieve this capability in Access.

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public
 
Reply With Quote
 
Tim Ferguson
Guest
Posts: n/a
 
      9th Sep 2003
"Morena" <(E-Mail Removed)> wrote in
news:528801c376ae$de1b8b40$(E-Mail Removed):

> Is there an access query way of counting the number of
> working days per month.
>


PARAMETERS InYear NUMBER, InMonth NUMBER;
SELECT DAY(DATESERIAL([InYear], [InMonth], 0) -
( SELECT COUNT(*) FROM Holidays
WHERE Holidays.HolDate >= DATESERIAL(InYear, InMonth,1)
AND Holidays.HolDate < DATESERIAL(InYear, InMonth+1,1)
)


The first line -- Day(DateSerial) gives the number of days in a month, and
the subselect counts the number of holidays in a table of holidays. I've
just realised that this doesn't do the weekends, but it shouldn't be too
hard to do a bit of WEEKDAY and MOD 7 stuff to get them out too.


HTH


Tim F

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Obtaining Forward EndDate with StartDate and Number of Days e.g. 30 (Number of days(30) excludes weekends and holidays Microsoft Access Forms 1 10th Sep 2009 06:25 PM
Calculate number of days query navin Microsoft Access 4 18th Mar 2008 12:13 PM
Access query work days function over 20 days =?Utf-8?B?ZGJ3b25nODg=?= Microsoft Access Getting Started 3 17th Oct 2007 06:28 PM
Number of Days between in Parameter Query ChuckW Microsoft Access Queries 2 9th Jul 2004 01:16 AM
Query that asks for dates x number of days away from today's date / comparing two fields in a query Mike H Microsoft Access Queries 2 22nd Dec 2003 08:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:37 PM.