473,662 Members | 2,454 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tricky Date Criteria

13 New Member
Hi,

I'm working on an HR database and I want to write a query that counts discipline records for the employees.

Here's the tricky part. Incidents are 'current' for two years. If an employee goes 2 yrs without an incident, their record is wiped clean. If they have an incident within the 2 yr mark, all previous records are counted no matter how far they go back.

Here are my fields:
DisciplineID
EmployeeID
ReviewTypeID (eg. Discipline or Performance)
DiscDate
DiscDescr
WarningID (eg. Safety, Attendance etc.)

Do I start by writing a query that sorts the most recent incident and weeds out people with a clean record?

Any thoughts on how to approach this would be much appreciated.

I'm not great at SQL or VBA so hoping for a simple solution in the query grid.
Dec 13 '12 #1
15 1914
NeoPa
32,568 Recognized Expert Moderator MVP
Hi Dani. Your explanation seems logically inconsistent - from the information posted. If the record is wiped clean when the employee remains clean for two years then any subsequent problem should only go back as far as the point where it was wiped. On the other hand, you suggest that a new offense causes all history to be shown.

I have an idea of how to set this up (with a subquery that groups by the employee and shows the Max of the date all linked in to the main table.) but the first step is always to have a very clear understanding of exactly what's required, so let's get that sorted first.

PS. I should commend you on a clear and well-worded question. Many people never manage such a succinct question :-)
Dec 13 '12 #2
Dani
13 New Member
Obviously I was still a bit muddy, but thank you :)

To clarify, if Employee has an incident in 2009 and nothing else until today, his incident in 09 would not be counted.

If Employee has an incident in 2009 and then in '10 and '11 and today, all previous incidents would be counted.

They are then issued a statement like, "As this is your fourth incident, you are now under suspension" Or "As you have no current incidents on record, you are receiving a written warning."

Basically they have to go a full two years to start clean.

I hope that clears it up. I appreciate any and all advice.

Cheers,
Dani
Dec 13 '12 #3
Rabbit
12,516 Recognized Expert Moderator MVP
I believe NeoPa's question was regarding whether or not the data is purged when their "slate is wiped clean". It sound like the data is still there so their slate is conceptually wiped clean but not actually wiped clean because their infractions are still in the table.
Dec 13 '12 #4
Dani
13 New Member
Excellent comment and not something I had considered doing. My first instinct is to preserve the information, but purging would be more in line with genuinely wiping their record.

The database is still in development stages so this is an excellent discussion for me to have with our HR Manager.

Thank you for this.
Dani
Dec 13 '12 #5
Rabbit
12,516 Recognized Expert Moderator MVP
I just want to say that I was not recommending that the records be deleted, there are arguments for either method. I was merely clarifying NeoPa's question.
Dec 13 '12 #6
NeoPa
32,568 Recognized Expert Moderator MVP
Explaining that a little more clearly (As Rabbit says it's not about deleting data), does data prior to a two year long gap get included if a subsequent infringement/issue is logged?

Consider the following situation where Employee A has incidents on the following dates :
31/1/2005
15/3/2006
1/1/2009
31/8/2009

At the end of 2009 a report is run. Both incidents in 2009 (1/1 and 31/8) are obviously included within the list. Are the previous incidents also included?

Bear in mind that your question stated :
  1. If an employee goes 2 yrs without an incident, their record is wiped clean.
  2. If they have an incident within the 2 yr mark, all previous records are counted no matter how far they go back.

These statements are mutually exclusive, hence we need clarification of the request. We haven't touched on technical details yet (which would include how to extract the information required - when we know what is required).

PS. I appreciate your earlier attempt to clarify, but I'm afraid it didn't really manage to clear up the issue.
Dec 13 '12 #7
Dani
13 New Member
It's a very valid concern about the process, so I thank you for bringing it to my attention. I've now discussed it with the HR Mgr and he has instructed me to purge an employee's record once they have passed the two year mark.

This simplifies the query writing since only employees with records will be in the table.

Thanks for your help Neopa & Rabbit,
cheers,
d
Dec 13 '12 #8
Dani
13 New Member
I missed this comment as I had not refreshed my screen:

"Explaining that a little more clearly (As Rabbit says it's not about deleting data), does data prior to a two year long gap get included if a subsequent infringement/issue is logged?"

No. In this situation they would start again at first Verbal Warning.

From a privacy standpoint, it seems better practice to purge the Employee's record once they're entitled to a clean record so old infractions are not viewed if they are not relevant.

You have both been very helpful in solving this--and without forcing me to use code! Very grateful :)
Dec 13 '12 #9
NeoPa
32,568 Recognized Expert Moderator MVP
Always a pleasure :-)

How do you propose to handle ensuring that such records that need to be purged are done so? How will this process be triggered?

Purging the data certainly makes the process a lot more straightforward of course. It might be possible to achieve without, but certainly not straightforward as far as I can see.
Dec 13 '12 #10

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

Similar topics

11
4218
by: David B | last post by:
I have 2 querys with the following in the date criteria Between DateAdd("m",-6,(!!)) And (!!) Between DateAdd("m",-24,(!!)) And DateAdd("m",-6,(!!)) Problem is they both look at the same day 6 months before the date entered. eg date entered = 28/02/2004 then both querys pick up data from 28/08/2003
2
1620
by: Rene | last post by:
I have a master "attendance" report that also has two "attendance" sub-reports...each collecting data from a different group...and totaling those present at the end. I chose sub-reports because of the way they needed the data displayed. When printing this report, they wanted an option to select by date. The sub-reports are linked to the master by this "date" field.
2
1318
by: ljn | last post by:
Hello, I'm trying to build a query to retrieve all records where a certain date is older than 120 days. I tried doing > 120 in the critera box for that date, but it's not working. Any ideas? Thanks!
1
346
by: Mark | last post by:
Hi All, Below is part of a Union query which I can't get to work. I have a pop-up form which asks the user to enter a date and select from 2 option buttons. Once they have done this, the query will run. Each time I try to run the query, I get the message "This expression is typed incorrectly or is too complex to be evaluated. I'm certain it's the criteria that's at fault. the field is of general date, date/time format. SELECT...
10
3266
by: Daniel | last post by:
In Microsoft Access I can write a query that includes the criteria: Between Date()-7 And Date() to retrieve the records from a table that fall within the last week. I'm trying to write a procedure to do this in VB.NET (2005 Express Edition). But I always get the message that the Jet database engine does not recognize the syntax (of the Date function I assume). I've also tried Now() and it works but only by itself. I seem to add or
0
1554
by: zeusspandex | last post by:
Im creating a cross tab query which sorts via and sums the for each type of . I want to be able to add a date criteria, so the user can specify that the query processes data between two dates. I have looked long and hard on the net for any answers and it seems that this has appeared often but without a proper solution. I offer the following SQL of my query: Code: ( text ) PARAMETERS !! DateTime, !! DateTime; TRANSFORM...
1
1561
by: zeusspandex | last post by:
Hi, i have the following SQL query and would like to add date criteria to it. the field being from the table and the criteria being Between !! And !! query: SELECT , Sum(IIf(,,0)) AS RecycTonnage, Sum() AS TotTonnage,
2
4325
by: kashif73 | last post by:
Hi, I want to export data from 4 Access tables to Excel using VBA. The user selects 2 different DATES from the form & based on DATEs criteria all record from 4 tables should be extracted to excel. I can extract data from Table 1 to excel, which has the DATE field. But other 3 tables doesn't have this DATE field. I was wondering how can I get data in Excel from other 3 tables?? All 4 tables have 1 field in common "REFNO". This field is the...
5
4831
by: sh55555 | last post by:
I have built a query in Access using the DateSerial function to convert dates such as 20100401 to 04/01/2010. The query results work fine and the date is displayed correctly. I am now trying to enter criteria to query only certain dates. When I enter 04/01/2010 in the criteria field it displays a "data type mismatch error". I have tried entering the date criteria as #04/01/2010# and I get the same message. Ultimately I would like to create...
9
6222
by: Raza Zahur | last post by:
Hi all, I've googled and googled but I can google no more, so I am here to ask for help on an issue I am having. I have a macro that runs a series of queries. Before the macro can be run, the date criteria of maybe six or seven queries needs to be updated to reflect the current week ending date. The simple way that I usually do this is to make a form and have the queries grab the date criteria entered on the form and then have a button to...
0
8856
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8762
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7365
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5653
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
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 we have to send another system
2
1747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.