sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
jjkeeper's Avatar

Calculating No. of Days excluding Public Holiday


Question posted by: jjkeeper (Newbie) on August 25th, 2008 02:12 AM
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
4 Answers Posted
JM420A's Avatar
JM420A August 25th, 2008 01:38 PM
Newbie - 6 Posts
#2: Re: Calculating No. of Days excluding Public Holiday

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
missinglinq's Avatar
missinglinq August 25th, 2008 03:56 PM
Moderator - 2,614 Posts
#3: Re: Calculating No. of Days excluding Public Holiday

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)>
jjkeeper's Avatar
jjkeeper August 27th, 2008 06:17 AM
Newbie - 10 Posts
#4: Re: Calculating No. of Days excluding Public Holiday

Thank you both!

@missinglinq, sorry but where's the link? I can't find.
missinglinq's Avatar
missinglinq August 27th, 2008 02:35 PM
Moderator - 2,614 Posts
#5: Re: Calculating No. of Days excluding Public Holiday

Sorry! Apparently the editor was in Stealth Mode!

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

The second example deals with holidays.

Linq ;0)>
Reply
Not the answer you were looking for? Post your question . . .
197,049 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 197,049 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Microsoft Access / VBA Contributors