473,465 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Calculating No. of Days excluding Public Holiday

10 New Member
G'day, I'm currently working on an annual leave database for the company, so far so good, till they want the database to be able to identify public holidays and prevent reducing the employee's balance if the application overlaps with the holiday. I'm using access 2000. Here's what I have so far.

tblMainProfile - contains employee's profile
EmployeeID <== Pkey
Name
Date of Birth ..

tblLeaveApply - link to tblMainProfile by EmployeeID
LeaveID <=== Pkey
EmployeeID
DateFrom
DateTo
Half day (AM/PM)
Days <=== number of days between DateFrom and DateTo for that record
LeaveTypes
Year ..

tblLeaveEntitlement - link to tblLeaveApply by EmployeeID
Index <=== Pkey
EmployeeID
Year
LeaveType
LeaveEntitled

And then I have a query to calculate TotalDays, by
Expand|Select|Wrap|Line Numbers
  1. TotalDays: Sum(Nz([Days],0))
and DatesLeft, which is the leave balance,
Expand|Select|Wrap|Line Numbers
  1. DaysLeft: [LeaveEntitled]-[TotalDays].
This query is then used for sub-form1, linking EmployeeID with the Mainform.

The mainform shows that employee's profile (ID,name,department,nationality). Sub-form2 bounded directly to tblLeaveApply, is for employees to input in the dates and leave types to apply for leave. The order is:
1) employee chooses DateFrom and DateTo, AM/PM if halfday.
2) employee then clicks on a button to calculate the number of days between DateFrom and Dateto, and if AM/PM = Is Not Null, the Days-0.5. (calculations for the button is done in VB, on-click event).

If possible, can you recommend a design such that when the employee picks DateFrom, DateTo and AM/PM if applicable, and then clicks on the button to calculate number of days, the database checks through tblPH, and for every PH_Date that is within DateFrom and DateTo, then Days-1.

Well, I roughly know the logic, but this is more or less my first time actually doing a database, so I can't figure it out in terms of a database application. I tried using SELECT count function in query but it showed me 26, when I only have 2 PH_Dates in the table. So I'm a little puzzled. Plus, let's say that count function works, I can't figure out how to implement it into the form too.

Thanks,
Johnny
Aug 25 '08 #1
5 3145
JM420A
8 New Member
As a thought, You could have a separate table that holds the date and title of your National Holidays. From there, you could do a query that searches for the dates where date not in (select * from holidaytable). My syntax is jacked up I'm sure, but it is more to give you an idea to start from.

hope that helps.

jm420a
Aug 25 '08 #2
missinglinq
3,532 Recognized Expert Specialist
JM420A has the right idea. The concept involved here is similar to that of calculating the working and non-holiday days between two dates. Here's a link to two routines for doing this. Studying them should help you in your task.

Welcome, JM420A and jjkeeper, to Bytes!

Linq ;0)>
Aug 25 '08 #3
jjkeeper
10 New Member
Thank you both!

@missinglinq, sorry but where's the link? I can't find.
Aug 27 '08 #4
missinglinq
3,532 Recognized Expert Specialist
Sorry! Apparently the editor was in Stealth Mode!

http://www.mvps.org/access/datetime/date0006.htm

The second example deals with holidays.

Linq ;0)>
Aug 27 '08 #5
sudowtariq
1 New Member
missinglinq Thanks for the code you've wrote. It was really helpfull.
Dec 19 '14 #6

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

Similar topics

4
by: John | last post by:
hey all..... alright, I am frusterated to the point of throwing my machine out the window (this board went down, trying to find stuff on google, this has been a nightmare) so I hope you guys can...
12
by: Anthony Robinson | last post by:
Is anyone aware of a function (system or user defined) that will calculate business days? For instance: I have a column in as table called DATE. I want to be able to add five business days to that...
4
by: CDMAPoster | last post by:
I'm starting to come up with a version of DateAdd that I call BusinessDateAdd that adds the selected number of business days. It's still in preliminary form (needs testing) and interacts with my...
9
by: trogenone | last post by:
Hello Im new to this and need a hand. Sorry if i have posted this in the wrong area. I am working on a small database it consists of two tables: Employees & Holidays Employees field are: ...
3
by: Jim | last post by:
Guys I'm rusty. Haven't messed with Access in a while. I'm trying to determine how many workdays (or weekdays) between two dates. I don't think their are any "canned" functions within access -...
4
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi, I have a web application that I need to add 3 days to the Now day, but need to make sure that I skip weekends and holidays. For example if Now is friday, 3 days + now should be tuesday,...
8
by: =?Utf-8?B?QWw=?= | last post by:
I am working in vb2005. how can I calculate business days (not including holidays and weekends) between 2 dates? thanks Al
1
by: geraldjr30 | last post by:
hi, i have the following to calculate working days between 2 dates, but i am not getting the right amount. i should be getting 11 instead of 12, because feb 16 2009 was a holiday. can someone...
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: 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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.