473,396 Members | 2,009 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,396 software developers and data experts.

Calculating Vacation Days Based On Time At Company

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:

Employee ID Auto no No duplicates Key
Full Name Text
Start Date Short date field
Length of Service Text/ Date to age query set in the field (Working)

This gives me years served ok. Now in the second table there is another field called Service Entitlement. What i need is for the database to look at the years served and if that employee has served over 2 years he/she get 1 extra day on their holiday allowance. The formula for the extra holiday is:

2 Yrs = 1 extra day
3yrs = 2days
4 = 3days
5 = 4days
6 = 5 days

I hope that makes scence. So in the Holiday table the field marked Service Entitlement should show the number 1 if the employee has served 2 years.

Sorry for the essay but if you can help i would be very greatful.

Kind Regards
Brian Warren
Dec 20 '07 #1
9 4116
jaxjagfan
254 Expert 100+
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:

Employee ID Auto no No duplicates Key
Full Name Text
Start Date Short date field
Length of Service Text/ Date to age query set in the field (Working)

This gives me years served ok. Now in the second table there is another field called Service Entitlement. What i need is for the database to look at the years served and if that employee has served over 2 years he/she get 1 extra day on their holiday allowance. The formula for the extra holiday is:

2 Yrs = 1 extra day
3yrs = 2days
4 = 3days
5 = 4days
6 = 5 days

I hope that makes scence. So in the Holiday table the field marked Service Entitlement should show the number 1 if the employee has served 2 years.

Sorry for the essay but if you can help i would be very greatful.

Kind Regards
Brian Warren
Put something similar to this in your query.

Holiday Allowance: iif((DateDiff ("yyyy", [Start Date], Date()) >= 6, 5, iif((DateDiff ("yyyy", [Start Date], Date()) = 5,4,iif((DateDiff ("yyyy", [Start Date], Date()) = 4,3,iif((DateDiff ("yyyy", [Start Date], Date()) = 3,2,iif((DateDiff ("yyyy", [Start Date], Date()) = 2,1,0)))))

Date() is simply today's date. The DateDiff function is returning the number of years ("yyyy") of service between the start date and today's date.

I assumed if less than 2 then 0 days and if great than or equal to 6 then 5 days.

I would have put the data in a table and done a lookup instead of in a formula.
Dec 20 '07 #2
FishVal
2,653 Expert 2GB
Nice.

But it has a substantial drawback.
datediff("yyyy", #12/31/1#, #1/1/2#)
will return 1 year. :)
its better to calculate difference in days and divide by 365 (366-days years ignored ;))
int(datediff("d", [StartDate], Date())/365)

Regards,
Fish
Dec 20 '07 #3
Rabbit
12,516 Expert Mod 8TB
Nice.

But it has a substantial drawback.
datediff("yyyy", #12/31/1#, #1/1/2#)
will return 1 year. :)
its better to calculate difference in days and divide by 365 (366-days years ignored ;))
int(datediff("d", [StartDate], Date())/365)

Regards,
Fish
To account for the 366-days year you could divide by 365.25 lol.
Dec 20 '07 #4
missinglinq
3,532 Expert 2GB
Fish is right on the money! DateDiff() returns a variant (Long Integer) so that, in essence,

DateDiff("yyyy", X, Y)

only returns the difference between the year value for X and Y. The difference in "years" can, indeed, be 1, while the difference in days can be also be 1! Generally speaking, as Fish hinted at, when using DateDiff(), you need to use a time unit lower than the unit you're actually interested in, and then parse the results! So if it's years you're concerned with, you can use days then divide by 365 (or 365.25, to keep Br’er Rabbit happy.) If you were interested in days, which is to say units of 24 hours each, you’d use DateDiff() with hours, then divide by 24.

Welcome to TheScripts!

Linq ;0)>
Dec 20 '07 #5
FishVal
2,653 Expert 2GB
To account for the 366-days year you could divide by 365.25 lol.
Let some of those good people receive extra day vacation one or even two days earlier.
lol
Dec 20 '07 #6
Put something similar to this in your query.

Holiday Allowance: iif((DateDiff ("yyyy", [Start Date], Date()) >= 6, 5, iif((DateDiff ("yyyy", [Start Date], Date()) = 5,4,iif((DateDiff ("yyyy", [Start Date], Date()) = 4,3,iif((DateDiff ("yyyy", [Start Date], Date()) = 3,2,iif((DateDiff ("yyyy", [Start Date], Date()) = 2,1,0)))))

Date() is simply today's date. The DateDiff function is returning the number of years ("yyyy") of service between the start date and today's date.

I assumed if less than 2 then 0 days and if great than or equal to 6 then 5 days.

I would have put the data in a table and done a lookup instead of in a formula.

Thank you i will try this and see how i go. Yes your quite correct if before 2 yrs service 0 extra days and over 6 you still only get the 5.

Thank you again

Brian
Dec 21 '07 #7
Rabbit
12,516 Expert Mod 8TB
Please use a clearer title next time.
Dec 21 '07 #8
Please use a clearer title next time.

DIFFICAULT IF YOUR NOT SURE WHAT YOUR ASKING MR !
Dec 26 '07 #9
Rabbit
12,516 Expert Mod 8TB
DIFFICAULT IF YOUR NOT SURE WHAT YOUR ASKING MR !
I can only hope you're joking with this post.
Dec 28 '07 #10

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...
1
by: Chris Strug | last post by:
Hi, As something of a pet project, I'm looking to develop a tool to track employee holiday (or vacation for those of us in the US) for my company - good for the company (if I get something...
2
by: celsius | last post by:
Hi folks, Al Bowers wrote this program on comp.lang.c Date: 2001-07-09 13:41:58 PST #include <stdio.h> int isleap (unsigned yr); static unsigned months_to_days (unsigned month); static long...
3
by: Ron Vecchi | last post by:
I need to calculate the age of a person based on a DateTime BirthDate I was thinking TimeSpan ts = DateTime.Now - BirthDate; //I can get the days but not years. // I could check each...
3
by: Miller | last post by:
Hi, Can someone tell me how to calculate MFLOPS for the following C# code (on a Pentium 4 2.0 Ghz)? for (i=0; i<n; i++) { for (j=0; j<n; j++) { for (k=0; k<n; k++)
3
by: mlcampeau | last post by:
Hi guys, I am trying to run a query that calculates when employees become eligible for supplemental vacation. This occcurs once the employee has reached 5, 10, 15, etc years of service. I got the...
2
by: JennDavila | last post by:
Hello, I am running into an issue with adding a form that displays a calendar to where the manager can click a day and it will attach itself to a tracking table. I am new to this and have been...
5
by: jjkeeper | last post by:
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...
1
by: trixxnixon | last post by:
Hi all, I have been handed a new project that required me to update a database... a rather complicated database. I take that back, its not that it is super complicated, I am just a novice user...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...

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.