473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

I would like to remove weekends & holiday from an access query

Hi all I would like to remove weekend and holidays from my access query: Here is the function i'm using. I tried using a exclude 1&7 for sat and sunday but it doesn't work...

Days Open:DateDiff("d",[Open Date],IIf(IsNull([Closed Date]),Now(),[Closed Date]))
Mar 25 '11 #1
4 6912
You should really use an auxillary calendar table:

http://sqlserver2000.databases.aspfa...dar-table.html
Mar 25 '11 #2
thanks, jpatchak! but could I just add to the function i have posted to remove weekends and holidays...
Mar 25 '11 #3
I'm not sure there is an easy way to exclude weekends and holidays with a function like that. If you had a simple calendar table with the following fields: Date, IsWeekend, IsHoliday your function would look something like this:

DCount("*", "CalendarTable", "(Date BETWEEN #" & [Open Date] & "# AND #" & NZ([Closed Date], Now()) & "#) AND IsWeekend=False AND IsHoliday=False")

Having a Calendar table will give more flexibility to add/take away holidays, etc... without changing your code. All you'd have to do to add Kwanzaa as an exluded holiday would be to check the IsHoliday field in your calendar table for whatever date Kwanzaa is.
Mar 25 '11 #4
Stewart Ross
2,545 Expert Mod 2GB
As jpatchak said, you really need to use an auxiliary table if you want to exclude holidays. There is no automated way of recognising these, as the specific days allocated as holidays vary not just country by country but regionally within many countries.

There are many, many possible variations of holiday dates. If an organisation schedules holiday dates at Easter, for instance, these will vary every year, as the dates for Easter itself are not fixed and can vary widely from one calendar year to another.

Companies can also set local dates for holidays which override other dates in the calendar. The only practical solution to counting or excluding specific dates as holidays is to store those dates in a table set up for that purpose. That in itself does not exclude them - there would be additional logic needed to do so either within an SQL function or a separate user-function, but without the table there is no chance of accommodating actual holiday dates at all.

The link jpatchak posted provides guidance on this topic and outlines comprehensively why and how an auxiliary table is used - I'd strongly advise you to have a look at it!

-Stewart
Mar 26 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: david liu | last post by:
access 2000 query: here's what i want to do. from an asp page, perform a search on a table in access. i have used sql code in the asp page itself, but i'd rather execute a query in access. i...
1
by: Jack | last post by:
Hi, I have a stored access query which is corresponding to a particular id. However, I am using a login script to capture the value of an id. Now, I want to dynamically open the stored query by...
5
by: Art | last post by:
Hi, Can anyone point me to an example of how I would execute a query I've created in an Access DB. I've copied the SQL down to my VB.net application and that works fine, but it's ugly. I'd like...
2
by: sumGirl | last post by:
Is it possible to run an access query from the scheduler? I need to update a table in the middle of the night, and so I would like to set up a job on a machine thats on all night so I dont have to...
8
by: s_wadhwa | last post by:
SELECT DISTINCTROW "01C" AS dummy, Buildings.BuildingNumber, UCASE(Buildings.BuildingName) AS BuildingName, Buildings.MasterPlanCode, Buildings.UniformBuildingCode,...
12
by: zwasdl | last post by:
Hi, I'm using MS Access to query against Oracle DB via ODBC. Is it possible to use HINT in Access? Thanks, Wei
1
by: EwanD | last post by:
I am trying to read through and process an Access Query using VBA. I have used the OpenRecordset method with parameters as below OpenRecordset(sSourceRecordset, dbOpenDynaset) Where...
6
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one...
3
by: winterwind | last post by:
I want to remove one row from table by clicking on remove link(one for each row) and change their id's correspondingly(like remove 2nd row and assign 3rd row id=2nd row id i.e.,shift row id's)
0
by: uno7031 | last post by:
Help Please!!! Adding 5 Days to another Date in an access query Good Morning, Help please…. I am new to access and trying to write a query that will add 5 days between a RecDate and a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.