Queries :: Compare Records From Two Different Dates

Jun 11, 2013

I have a table that contains the following fields: ID (autonumber), Item, billing date(mmm/yyyy), count, and approved.

My first query returns records where the approved field is null. My second query returns returns all records for 2 months ago where the approved field is not null.

This is my problem, I need to pull records that have NOT been approved for the prior month BUT if they were approved 2 months ago AND the count is the same, it does not need to be returned in the query. Also, if it was approved 2 months ago but the count is different than what it is for 1 month ago, it needs to show in the query.

View Replies


ADVERTISEMENT

Queries :: Compare Fields In Different Records For Changes

Jul 18, 2013

I have a table called tblAuthorizations. It appears as follows

AuthInstanceID....ConsumerID....AuthNumberID....Au thStart....AuthEnd....PSRUnits....BSTUnits
1374006036.........356679..........20255102....... ...4/22/13......7/21/13.....0..............416
-432536491.........356679...........20255102....... ...1/21/13.......4/21/13....104..........416
-124970517.........356679...........20147863....... ...10/23/12.....1/20/13....208..........520
504564357...........469432..........20254788...... ....4/22/13......7/21/13....0..............520
282523535...........469432..........20254788...... ....1/21/13.......4/21/13....0.............520

I work in mental health, and when we put in a request for a consumer to receive PSR & BST services, we put the above information into our database. Each record identifies which consumer the authorization is for, a start date and end date for them to receive services, and the amount of two types of services (PSR and BST). When one period ends, we request another period, such as in the first three records above, and then the final 2 for another consumer.

What I need to be able to tell is how their service authorizations change. For instance, if I were to compare the first and second records, it would tell me that PSRunits decreased 4/22/13-7/21/13 from 1/21/13-4/21/13 levels.

I have a query that displays the records for each consumer for the current period, but I can't figure out how to identify the previous period's number of PSRUnits or BSTUnits.I've tried adding the following fields, but this isn't working.

PrevEnd: (Select Max(AuthEnd) from tblAuthorizations Where AuthEnd < Auths.[AuthStart])
PrevBST: DLookUp("[BSTUnits]","tblAuthorizations","AuthEnd=" & [PrevEnd] And "ConsumerID=" & [ConsumerID])

View 2 Replies View Related

Queries :: Calculation To Compare Different Records

Feb 28, 2014

I have created a mock employee database to work out kinks before I create the real one. One table has employee info (employeeID, name, address, email, phone numbers, etc.). The other table has "employee actions" with fields: employeeID, actiontype, salary, jobtype, jobtitle, jobhours, bonus, actiondate. Actiontypes are "hire", "salary change", "bonus", "leave". It is a little more complicated but that is irrelevant to my query question...

I created a query to show employee salary changes, amount and action date. I want to create a calculated field that shows the dollar change and percentage change from last salary to new salary. So the query involves multiple records or rows, which seems to be a black hole in terms of information on how to do this. If it were Excel, I would just do a quick nested function calculation and be done with it but with Access, where each record is independent of the others, how to calculate it. I know there must be a way to do this because otherwise, what good would an employee database be?

So the questions are: (1) can you do calculations (other than totals or counts) using multiple records/rows? and (2) if so, how do I do it? It seems I would have to do a a specific sort and it would not be easily updatable.

View 12 Replies View Related

Forms :: Compare Dates In Two Fields?

Jun 18, 2014

I would like to change the colour of field on a form if the date in that field is later than the date in another field.

View 9 Replies View Related

Compare Dates In 2 Unbound Text Boxes

Feb 20, 2015

On a form I'm asking a user to enter dates in 2 different textboxes, say, [text1] and [text2], both formatted to short date. In a third textbox [text3] I need to see the date of the greater of the two, and in a fourth [text4] I need to see the date of [text3] if it falls on a Monday through Friday, or the date of the previous Friday if [text3] falls on Saturday, and the date of the following Monday if [text3] falls on a Sunday.

...a couple quick examples;

If text1 = 2/20/2015 and text2 = 2/27/2015, text3 should evaluate to 2/27/2015, and text4 should evaluate to 2/27/2015
or
If text1 = 2/20/2015 and text2 = 2/28/2015, text3 should evaluate to 2/28/2015, and text4 should evaluate to 2/27/2015

My attempts to compare text1 and text2 revolve around an IIF but result in an error...

Entering this into [text3]... IIF([text1]>[text2], [text1], [text2])

results in "#Name?" error, which I interpret as meaning the date from the source cannot be pulled into the formula.In attempt to check the day of week, I used =Weekday([text3],1) which results in a number. I haven't been able to do an IIF on it as it errors with #Name? again.

View 3 Replies View Related

Queries :: Finding Records Between Dates?

Jun 4, 2013

I have a table tbl_PolicyDetails with details of the policy the customers have with us.. In the tbl_PolicyDetails, I have two fields (these are the ones in question) called

"policyStarted" - Start Date of a Policy and
"policyPeriod" - Term of Policy Monthly/Annually/Quarterly

So in a Form view I just get the Next installment for the customer based on this information for display.. For example..

Mr Butters Stotch's policy started on 26/04/2013 and is paying Quarterly; the next (i.e. 2nd) installment would be on 26/07/2013..

Ms Wendy Testaburger's policy started on 07/04/2013 and is paying Monthly; the next (i,e. 3rd) installment would be on 07/06/2013..

This is not hard to get.. I have that sorted.. But the problem is, my manager wants to be able to specify two dates and search all policies that will be 'paying in' that Date range should be picked up..

So if the search range happens to be.. 01/07/2013 and 31/07/2013 Then Mr Butters Stotch's policy should be picked up, as his next installment falls on 26/07/2013.. Since this information is not stored, I cannot run a direct Query on this.. Also as the Installment number varies for each customer, I would not be able to just add 1 - Month or Quarter or Annum, and see if the date falls in that range..

View 2 Replies View Related

Queries :: Query For Records Between Two Dates

Jun 5, 2013

Only one table : Customer ID,Customer name , subscription period, subscription start date and subscription end date.

I need values where subscription start date is between date1 and date2 and subscription end date is between date 1 and date2.

Detail explanation:

customer1 subscribed from 2-feb 2012 to 2-feb 2013
customer2 subscribed from 5-aug-2012 to 5-aug-2013
customer3 subscribed from 1-Jan-2013 to 31-Dec-2013
when the user enters date 1 as 1-jan-2013 and date 2 as 30-Jun-2013

Even though the subscription start date is not within the range entered by the user.I need to get all three customers because the subscription enddate falls within the range.And customer 3 is also required as subscription start date is within the range.

View 2 Replies View Related

Queries :: Query To Filter Records Between Dates

Feb 19, 2015

I have a few queries which are used to create reminder email on training which is due for renewal.Some training required reminder 6 months before 2 year expiry. I use this in the criteria for the training date within query:

Between DateSerial(Year(Date()),Month(Date())-18,1) And DateSerial(Year(Date()),Month(Date())-17,0)

Some training required reminder 3 months before 1 year expiry. I use this in the criteria for the training date within query:

Between DateSerial(Year(Date()),Month(Date())-9,1) And DateSerial(Year(Date()),Month(Date())-8,0)

My problem is with training requiring reminder 6 months before 3 year expiry. Using this criteria:

Between DateSerial(Year(Date()),Month(Date())-30,1) And DateSerial(Year(Date()),Month(Date())-29,0)

Doesn't show any results (although there is training which was done 30months ago, expiring in 6 months time).

Changing the -30 (months) and -29 (months) in above down to -22 & -21 shows records as expected, but anything below -22/-21 doesn't show any records.

View 3 Replies View Related

Queries :: Eliminate Records With Dates In Same Month

Jun 17, 2015

I am trying to figure out a logical WHERE condition. I have a Query that gives me data,

Code:
Name | Start | End
--------+-----------------+-------------
Paul | 30-May-15 |
Eugin | 21-May-15 | 28-May-15
Francis | 04-Mar-15 | 08-May-15
Samuel | 10-May-15 | 13-May-15

I want to have only Paul and Francis. As Eugin start is 21-05-2015 and End is the same month, so is Samuel's. So I want to eliminate those two records.I have checked pbaldy's web of overlapping records. But unlike that, I need something customised.

Begins and ends before range - we don't want - Yes
Begins before, ends during - we want this one - Yes
Begins and ends during - we want this one too - NO
Begins during and ends after - we also want this one - Yes
Begins and ends after - we don't want this one - Yes
Begins before and ends after - we want this one -NO

View 5 Replies View Related

Queries :: How To Get Latest Dates And 3 Other Data For Records From A Table

May 29, 2015

Giving up after a zillion tries. I have a table (tblLOADS) containing: BROKER, PUDATE, MATERIAL & DRIVER. I am able to create this query:

SELECT tblLOADS.L_ID, tblLOADS.BROKER, Max(tblLOADS.Pudate) AS MaxOfPudate, tblLOADS.Material, tblLOADS.Driver
FROM tblLOADS
GROUP BY tblLOADS.L_ID, tblLOADS.BROKER, tblLOADS.Material, tblLOADS.Driver
HAVING (((Max(tblLOADS.Pudate))>0));

Problem: It's datasheet view displays all of the records for BROKERS, PUDATE, MATERIAL & DRIVER, instead of ONLY the records for the last PUDATE of each of the BROKERS, with their corresponding MATERIAL & DRIVER fields.

View 12 Replies View Related

Queries :: Return Records Between Dates Based On 2 Date Fields In A Table

Apr 24, 2013

I have a table which includes a start date field and completion date field for housebuilding.

I am trying to extract all records that have either a started date or a completed date between 2 dates supplied by the user. I have tried to use Between on both fields but that doesn't return results between the fields.

It workd if I just do it on EITHER the start date field OR the completion date field so that implies to me that I need to break it into 2 queries, one returning start date recrods and the other returning completion date records but then I would need to have somthing that removes records that appear in both the start date and the completion date results.

View 7 Replies View Related

Queries :: Combine 4 Tables Data That Falls Within Dates - SQL Query Returns No Records

Oct 2, 2013

I have a complex database app that has a form called from the main form. It requires two inputs: BeginningDate and EndingDate and I use a calendar picker for date selection. Using data assigned to a variable, I build the SQL query in VBA. The result is:

Code:
SELECT [1733_All Print Orders].[Application], Sum([1733_All Print Orders].[TotalImages]) AS SumOfCCPC
FROM [1733_All Print Orders]
WHERE [Application] = 'CCPC' AND [StatementDate] >= #9/3/2013# AND [StatementDate] <= #9/30/2013#
GROUP BY [1733_All Print Orders];[Application]

[1733_All Print Orders] is a defined query that combines 4 tables together and there are data that falls within the dates for CCPC. But the query returns no records.

I pasted the query to the query builder and using different combinations, I isolated that the [StatementDate] >= #9/3/2013# portion is what returns no records

To complicate matters even worse, prior to today, it worked. I made some adds and changes to another area of the application, but did not touch this code.

View 1 Replies View Related

Queries :: Retrieve Records From One Table Where Dates Are Between Records In Another Table

Dec 30, 2013

I have a survey database that I've been using for the last year for monthly auditing of employees files. I need to be able to get monthly audit scores for each employee but grouped by their manager. The problem I'm having is employees have moved between managers throughout the year, so employees that are listed under Manager 2 now were actually working for Manager 1 when the audits occurred.

ie. Audits occurred Jan - April for Employee 1 while they were assigned to Manager 1. Employee 1 moved to Manager 2s team in May. So when running monthly reports for the year Employee 1 audits should fall under Manager 1 for Jan-April and Manager 2 for May-Dec.

I do have a history table set up like:
tblEmployeeHistory
ID (PK)
EmployeeID (FK to Employee table)
ManagerID (FK to Manager table)
MoveDate (date employee assigned to manager)

The Employee table is set up like:
Employee ID (PK)
EmployeeName
ManagerID (FK to Manager table)

The Manager table has the ManagerID and ManagerName.

That's the employee side of things; then I have the tables that store the audit results:

tblAudit
AuditID
FileNumber
AuditDate
EmployeeID (FK to employee table)

tblAuditResults
AuditID; QstnID (Composite PK, QstnID is FK to tblQuestions)
Answer

How can I use AuditDate and MoveDate to relate audits to the managers the employees were under when the audits occurred?

View 14 Replies View Related

How To Compare Records

Feb 6, 2004

Hello Ladies and Gentlemen,

My Access-table contains a Destination and Time field, i want to compare records for Time field with next records of same field.How can I do it..? Let me tell u an exp..
Time field is having a record like 06:23:45 AM for the destination - 'A', so i want to get all the records where the difference is upto 5 Seconds (i.e - 06:23:50 AM) and the Destination is same. It might be possible that there are one more records having time value 06:23:55 AM.

View 6 Replies View Related

Update And Compare Table Records

Sep 1, 2005

Hi
I'm using MS Office 2000, I have an Access database table that contain many fields, namely I need to update FieldA from an Excel Spreadsheet according to the specified primary key of CustomerID. Is there a way to write automate process to import the records from an excel spreadsheet and then place those records in FieldA of the Access Database according to the corresponding CustomerID? The reason I ask is that these two fields are not exactly in the right order in my spreadsheet and my table and to do it manually will take lots of effort.

Your prompt response is greatly appreciated

Thanks

View 3 Replies View Related

Compare Actual Records To Expected

Jan 28, 2008

Not even sure where to start so if this isn't a query question, please point me in the right direction.

I work in a plant that has a number of cranes. Each crane should be inspected each shift (three shifts per day), each day (less Sunday).

I have exactly what I need to capture the inspections being done. Inspections are identified by crane #, shift, and date.

How do I determine if an inspection hasn't been done? How do I compare the inspections that have been entered against the standard of inspections for each crane, each shift, each day?

I am below average with Access on my best day so please type slowly and be specific. Thanks for any help you can give.

Forrest

View 5 Replies View Related

Modules & VBA :: How To Compare Two Records (Rating)

Jan 5, 2014

So I have a table:

table1: company_name, year_month, company_rating, rating_change

For each company, I would like to compare the rating from 201201 and 201202 (and keep going for each month) and if there's a change in the rating, update rating_change to the difference in rating values.

The company_rating is a value from 1 to 20.

How should I go about doing that?

View 6 Replies View Related

Compare Two Types Of Records From One Table

Aug 9, 2011

I am trying to create a query based on a transaction table which compares the time between two types of transactions.

The initial record would have "A' in the type field and the second record would have "D" in the type field.

each pair of A and D records would be matched on o_time and idnum fields, and I would want to pull each pair and us the datediff function on c_time, using records marked with A as the initial time and records marked with D as the followup time.

Is there any way to accomplish this in a single query or do I need to create two subqueries?

View 1 Replies View Related

Compare / Check If Records Are Duplicate Using Save Button?

Jan 9, 2014

I need to create a record of Users. I created a form with fields containing Username,FirstName,LastName & Email Address wherein the UserName is equals the value of the fields FirstName & LastName. I have a save command button and when I click it, I want it to be able to check if the new entry has a similar UserName that exists in the database, if it exists then it will allow me to edit the UserName and then save the data otherwise will allow me to save it.

View 3 Replies View Related

Queries :: Calculate Expiry Dates Of Training Courses - Due Dates Not Shown

Aug 28, 2013

I have built a query to calculate the expiry dates of training courses but I am trying to input a criteria so that only dates within 90 days of todays date show. I am using Date()<90 but it doesn't return the correct information. What the criteria should be for this?

View 1 Replies View Related

Queries :: List Of Dates And Records With No Matching Record OR Existing Record With Higher Date

Nov 24, 2014

I've been asked to get some information from my database and I'm a bit stuck.

I have a list of refunds in tbl_main and each one includes a dateReceived. I make a record in either tlk_located, tlk_unableToLocate or tlk_bulk depending on the outcome when we're trying to send the money back to whoever it belongs to. Each table has a time stamp (named locatedTime, unableTime and timestamp respectively) field

My manager wants me to report how many entries were unworked on each day in the year, and what the value of them was. An entry is unworked if there is no entry in either of the 3 tables.

So I need a query that lists a range of dates, and for each date counts the number of entries where tbl_main.dateReceived is <= to that date and either has no record in located,unable or bulk or has a record with a timestamp > than the date. (It has been processed now, but hadn't been on the date we are looking at)

I can manage a query that looks at a certain date that it prompts for on each run:

Code:
SELECT Count(tbl_main.trust2PK) AS CountOftrust2PK, Sum(tbl_main.amountRefunded) AS SumOfamountRefunded
FROM ((tbl_main LEFT JOIN tlk_located ON tbl_main.trust2PK = tlk_located.trust2FK) LEFT JOIN tlk_unableToLocate ON tbl_main.trust2PK = tlk_unableToLocate.trust2FK) LEFT JOIN tlk_bulk ON tbl_main.trust2PK = tlk_bulk.trust2FK
WHERE (((tbl_main.dateReceived)<=[cutoffDate]) AND ((tlk_located.locatedTime) Is Null Or (tlk_located.locatedTime)>[cutOffDate]) AND ((tlk_unableToLocate.unableTime) Is Null Or (tlk_unableToLocate.unableTime)>[cutOffDate]) AND ((tlk_bulk.timeStamp) Is Null Or (tlk_bulk.timeStamp)>[cutOffDate]));

I would like a query that lists all dates in a range, and shows the same information for each day listed.

View 9 Replies View Related

Queries :: Need To Compare 2 Fields

Jun 13, 2014

Need to compare 2 fields in a query, and return the larger of the 2 values in a 3rd field.

As in:

Field A=10 Field B=6 I need Field C to = 10.
Field A=5 Field B=6 I need Field C to = 6.

View 3 Replies View Related

Queries :: Access 2007 - Select All Dates Between Two Dates?

Apr 9, 2015

I have a table of records, which has within it two date fields (effectively, a 'start' and 'end' date for that particular record)

I now need to create a query to perform a calculation for each date between the 'start' date and the 'end' date

So the first step (as I see it anyway) is to try to create a query which will give me each date between the two reference dates, in the hope that I can then JOIN that onto another query to perform the necessary calculation for each of the returned dates.

Is there a way to do this?

So basically, if for a particular record, the 'start' date is 01-Apr-2015 and the 'end' date is 09-Apr-2015, can I produce a dataset of 9 records as follows :01-Apr-2015

02-Apr-2015
03-Apr-2015
04-Apr-2015
05-Apr-2015
06-Apr-2015
07-Apr-2015
08-Apr-2015
09-Apr-2015

(The *obvious* solution would be to create a separate table of dates, from which I could just SELECT DISTINCT <Date> Between #04/01/2015# And #04/09/2015# - but that seems like a dreadful waste of space, if that table is only required to generate the above? And it would have to cover all possible options; so it would either have to be massive, and contain every possible date - ever! - or maintained, adding new dates as necessary when they are required. Seems horribly inefficient!)

Is it possible to just select each date between the two reference dates? Or can you only query something which exists somewhere in a table?

View 4 Replies View Related

Modules & VBA :: Query To Compare Values To Show All Records Where Form Combo Value Is Selected

May 1, 2014

I am building a tracking database where we would be able to track information which field are null data and report them to our Administration to fill the null data. For this I have created a form name "Search" and I have a combo box control on that form which is bound to "Table = employee" and its ROW SOURCE TYPE="Field List", I would like to able to query records where the selected value in this combo box is null through out the table.

For example if I select "Telephone" from this combo box dropdown, I would like the query to show all the records where the "Telephone" is null, how to set the criteria in query to take the combo box value as "Field Name" and then compare it with the Field/Column in the table and show the null values.

View 4 Replies View Related

Queries :: Compare Data Stored Within Same Table

Jun 13, 2013

I am running into an issue when trying to compare data stored within the same table.

tblParcels - holds data relating to an individual parcel of land; unique identifier is ParcelID. No repeating data.

tblValues - holds data relating to the value(s) of each parcel; new values entered annually; unique identifier is TaxID; has field to link to tblParcels. One parcel can have multiple entries for each year tracked.

I have two unbound text boxes on frmMainForm where users can enter Tax Years to compare (txtYear1 and txtYear2). Theory being that users will be able to select any two tax years and compare the parcel values.The report (rptMaster) is built using three queries and is used to show the change in value between txtYear1 and txtYear2:

qryYear1 - pulls all values from tblValues where the TaxYear equals the year typed in txtYear1.

qryYear2 - pulls all values from tblValues where the TaxYear equals the year typed in txtYear2.

qryCompare - joins the results from qryYear1 and qryYear2, along with other common fields, and populates rptMaster.

My problem lies when a parcel does not have any values for one or both of the years entered into the text boxes. I completely understand why, qryCompare can't show any records if there are no results coming from either qryYear1 or qryYear2. What I am not getting is how to work around this issue.I would like for the report to show "$0.00" for the value if there is not a value for that Parcel in tblValues for the year entered.

tblValues example data:
TaxID ParcelID TaxYear Value
1 5 2011 100,000
2 5 2012 200,000
3 6 2012 75,000

In the example above, when comparing 2012 values to 2011 values, my report shows the values for ParcelID 5 but not for ParcelID 6 as it does not have a 2011 value (and won't since information about that parcel didn't exist in 2011).

View 5 Replies View Related

Queries :: Compare A Field In Another Table And Update Accordingly

Jun 25, 2015

I am programming an Acess Database, the primary data come from an excel sheet. Since Access one to many relationship only works for primary key and another field in another table as foreign key, I can't have normalized database.

I will explain what I mean with a hypothetical situation.

So, let's say I have two tables: WindowT1, CustomerT2.

WindowT1 has fields: WinID (the pk), WindowName.
CustomerT2 fields include CustID (pk), CustomerName, WindowName, WinID.

So, in table "CustomerT2', WinID is the foreign key and I need that field filled in to make one-to-many relationship between these two tables to work. CustomerName and WindowName will be imported and prefilled already from an excel file with append query.

My question is can I make a update query (after the initial append query that brings in the data into Access) such that the criteria is matching WindowName (from CustomerT2) and the update would be the corresponding WinID (the pk number from WindowT1) that would be filled in the field WinID (in CustomerT2)? I know for this to work tables must have relationship and I did that.

Is there a better way to accomplish this task? i.e. through a form (remember info will be prefilled, so can't use combo box to fill in another form field) or maybe can I do this using the first append query (that brings in data)?

I am not good at Macro or VBA. The only thing I have done in code builder is After Update event in forms while using combo boxes. So, if there is no easier solution, I will try to deal with codes.

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved