Count Dates From Two Different Tables
Jul 6, 2007
I would like to count only dates where the Close Date is less than or equal to the Target Date. Here is what I have done, but it does not work. any ideas how I might get this to work?
SELECT A.[SCA_Open Issue Tbl.ID] AS [IDCount],
A.[Criticality of Risk] AS [Criticality of Risk],
A.[Database] As [Database],
A.[Risk_assumed_without_mitigation] As [Risk Assumed WO Mitigation],
A.[OTS] As [OTS],
A.[Issue Closed Date] As [Close Date],
A.[Targeted Completion Date] As [Target Date]
FROM [EOY Closed SC&A Issues] A
UNION ALL SELECT B.[RefID] AS IDCount,
B.[complexity_desc] AS [Criticality of Risk],
B.[Database] As [Database],
0 As [Risk Assumed WO Mitigation],
B.[OTS] As [OTS],
B.[EndDate] As [Close Date],
B.[TargetEndDate] As [Target Date]
FROM [EOY Closed Risk Assessments] B
WHERE [Close Date] BETWEEN Date() <= [Target Date];
View Replies
ADVERTISEMENT
Jul 8, 2014
I have two tables with dates. Between (!) every two following dates in table1, I want to know the number of dates in table2. How do I write an SQL query for this? The tables I have are up to a few hundred records in table 1 and a few thousand records in table2. So to prevent that this takes hours I need a fast query.
To explain the query I need, for example:
table1
01/01/2014
15/01/2014
17/01/2014
30/01/2014
table2
01/01/2014
02/01/2014
05/01/2014
17/01/2014
18/01/2014
20/01/2014
21/01/2014
25/01/2014
So the answer of the query would be 2,0,4.
Explanation:
Between 01/01/2014 and 15/01/2014 in table 1 there are 2 dates in table2 (01/01/2014 is not included between the dates)
Between 15/01/2014 and 17/01/2014 in table 1 there are 0 dates in table 2
Between 17/01/2014 and 30/01/2014 in table 1 there are 4 dates in table 2
View 2 Replies
View Related
Nov 28, 2006
I have 2 dates. How do i count the number of days between the two dates?
View 14 Replies
View Related
Nov 19, 2004
I know this is a simple question.
Using the design view in access, what is the setting to get the total number of records between 2 dates?
Thanks
View 3 Replies
View Related
Dec 7, 2004
Hi
I am trying to count the dates in the datebase, if date given in the textfield and the date in the table are equal.
sql="select dateField,Count(dateField) from Exam WHERE dateField="+dateField+"";
xxx
View 14 Replies
View Related
Dec 9, 2004
Hi,
sql1="select dateField,Count(dateField) as CountOfdateField from Exam GROUP BY dateField";
rst1=stm.executeQuery(sql1);
while(rst1.next()){
String d2=rst1.getString("dateField");
c=rst1.getInt("CountOfdateField");
System.out.print(d2);
System.out.println("");
System.out.println(c);
while(rst1.next()){
if(d2.equals(dateField)&&(c<3))
{
flag1=true;
break;
}
else if(!(d2.equals(dateField))){
flag1=true;
break;
}
else if((c>=3)&&(d2.equals(dateField))){
flag1=false;
break;}
}
}
I am trying to execute the above part of code. But I am getting required output. Can u suggest me the changes in the code.
jyothsna
View 1 Replies
View Related
Jan 25, 2006
here goes
im trying to count the number in a group between a time period. the query takes a time period from a form runs then reports who and how many heres what i get
SELECT tblEstimate.Client, Count(tblEstimate.Recieved) AS MyCount
FROM tblEstimate
GROUP BY tblEstimate.Client, tblEstimate.Recieved
HAVING (((tblEstimate.Recieved)>=[Forms]![frmEnquireFront]![EqfromDate] And (tblEstimate.Recieved)<=[Forms]![frmEnquireFront]![EnqtoDate]))
ORDER BY tblEstimate.Client;
Client MyCount
Amey Vectra Ltd 1
Amey Vectra Ltd 1
Ashworth Mairs Group1
Property Consortium1
Property Consortium1
heres what im trying to achieve
Client MyCount
Amey Vectra Ltd 2
Ashworth Mairs Group1
Property Consortium2
am i going about this the wrong way
is there an easier way
any help would be great
thanks in advance
john:confused:
View 6 Replies
View Related
May 28, 2007
Hello,
I think this might be a typical question for query builders, so I apologize in advance for asking something so basic.
I have a form with two controls (start_date) and (finish_date).
Is there a way that I can create a query that will count the number of times a "source" has been entered into a table?
For example, I have a database where potential customers call and ask about our services. We ask them "Where did you hear about us?", hence the "source" field (which is a drop down combo box to normalize that field's data).
With this record is their "dateofcall" which is (obviously) a date field.
I'd like to create a report that will count the number of times a "source" has been entered between two dates "dateofcall" (the start and finish date above).
I have tried many types of queries and haven't found any success. The nice thing about the two form controls is that I can use those two controls for a variety of all types of queried reports. (the user enters a start and a finish date, fires a command button that generates a given report between those two dates). And it works well!
Can anyone help? I'd be most appreciative!
Mike
View 3 Replies
View Related
Sep 30, 2007
Is there a way to find out the number of Wednesdays between two given dates? Thank you.
View 10 Replies
View Related
Aug 25, 2011
I created a query and one of the fields in it is for dates. I need to create a report that will only count how many entries have dates and it shouldn't count those with no/blank dates .
Is there a way to put a criteria in my query for date field? What would be the formula? Or is there a formula that I can put straight to my report that will only count the ones with dates?
View 14 Replies
View Related
Apr 29, 2006
HI
I need to konw how to Count different dates in a subform query?
View 2 Replies
View Related
Nov 5, 2007
I've had it before, but can't find it.
basically something like this --
DateDiff("w", StartingDate, EndingDate)
that also makes sure date is not in tblHolidays.
anyone knows how to acomplish this ?
View 1 Replies
View Related
May 28, 2014
I just can't seem to get this one to work right. I've got the following query. I need to count the number of Null dates or show zero if there are no Null Dates.
Code:
SELECT DISTINCTROW qryNoticeResponseNew.fldNoticeID, Count(qryNoticeResponseNew.[fldResponseSeen]) AS fldCount
FROM qryNoticeResponseNew
GROUP BY qryNoticeResponseNew.fldNoticeID;
Which is just counting the number of dates so far. It got me to thinking I need to do something like this.
Code:
SELECT DISTINCTROW qryNoticeResponseNew.fldNoticeID, IIf(IsNull(qryNoticeResponseNew.[fldResponseSeen]),1,0) AS fldCount
FROM qryNoticeResponseNew
GROUP BY qryNoticeResponseNew.fldNoticeID;
Which pops a "cannot have aggregate function in expression" error.
View 2 Replies
View Related
Sep 30, 2014
I need the total of days in a report but exclude the repeated ones.
So user are working sometimes in different work orders on the same day but our administration only needs to know the number of days worked in one period of time.
i send a jpg with the example i use the =Nz(Count([Date Worked]),0) but that way i get all the entries counted
View 2 Replies
View Related
Aug 4, 2015
I want to do a unique count of dates when an activity was done in my table. The table may have multiple entries of the activity performed possibly on the same date by an individual
e.g. table entries
Code:
approvalNoSys dateAssessed Activity
100 01/08/2015 Audit
100 01/08/2015 Audit
100 01/05/2015 Audit
100 01/05/2015 Audit
100 01/02/2015 Audit
100 01/01/2015 Audit
Unique audit Count must equal 4
Code:
totV = ECount("[dateAssessed]", "R_P_Data_P", "[approvalNoSys] = '" & [Forms]![cmrOverview]![txtappNoSys] & "' AND [Activity] Like '*audit*'")
totV = Unique count
dateAssessed = date field in R_P_Data_P table
R_P_Data_P = table
"[approvalNoSys] = '" & [Forms]![cmrOverview]![txtappNoSys] & "' = criteria for the customer in question to separate them from many other customers in the table.
Activity = text field in R_P_Data_P table
audit = the activity
I'm also trying to avoid having to build total queries etc to them reference them, I'd like getting the desired outcome in an expression or small code.
I read about Ecount but my complier doesn't recognise the function
View 6 Replies
View Related
Jan 10, 2014
I have 2 linked tables, tblPN & tblReceivedDate. tblPN has field PN and tblReceivedDate has field [Received Date]. The tables are used to record the receipt of different part numbers and the date they received. I want to use a query to count how many times a part number is received. The catch is that I only want to count a part once even if it is received more than once on the same date. With the data in the attached DB the count for PN 123 would be 5.how to configure the query to do what I need to do?
View 9 Replies
View Related
Apr 30, 2014
I need to be able to count how many fields per date. I've tried several ways to add this to my query, but nothing seems to combine the dates, it just gives me nothing or 1 as the count for every line even when it is the same date......
View 3 Replies
View Related
Nov 9, 2013
DCount function.
Code:
Me.ImprovementNotice5DayCount = DCount("[txtReferralReason]", "qryRTOFileReferralPopupCount", "[ComplianceTargetDate]-[DateNow]<=5")
I am not sure where I have gone wrong.
What I would like Dcount to count are those dates in the ComplianceTargetDate form control that are <=5 to the DateNow form control.
I get a count of 3 when there is only one. I may have the syntax of the Dcount wrong.
View 4 Replies
View Related
Aug 21, 2013
So I have a report generated, listing all my companies personnel in one column and the next column has the expiration dates of a certian training certificate. My question i would like to add some statistics to the bottom of the report, mainly how many certificates are expired, which is the ones over a year.
I have attempted to use:
=Sum(IIf([AT_LEVEL 1]<"Now()-365",1,0))
previously in excel my spreadsheet counted it like this:
=COUNTIF(C5:C77,"<"&TODAY()-365)
View 3 Replies
View Related
Apr 30, 2014
I'm creating a form to count the number of employees with birthdays between 2 dates. There are 2 unbound date fields; Start_Date and End_Date. I have an Employee table with DOB field. I've been stuck on how to get the field to return the correct number of employees that fall within the 2 dates.
View 2 Replies
View Related
Jun 8, 2015
How can I calculate the difference between two dates but I only want to count the work days? So if was today and I wanted to go until 6/15/2015 the difference would be 5 and not 7 because I do not want to count Saturday or Sunday. Is there a special %datediff function where I would only count work days?
View 4 Replies
View Related
Mar 18, 2013
I currently have a query of between dates which the user enters, but when I try to get a total count of model numbers it gives totals for each date. I am trying to get a count of model numbers between these dates with the dates excluded in the grouping.
View 14 Replies
View Related
Jul 3, 2015
I am using Access 2013.I am trying to create a query that will count the days difference between two dates. The dates are in the same field. I want to group by Region.So:
tblRegion = RegionID
tblStatus = StatusDate
I know how to use the DateDiff when it is two different fields, but I can't figure out how to do it from the same field.
View 7 Replies
View Related
Nov 8, 2012
I have just started using Access 2010. I need to calculate student's ages from their date of birth to today's date. I have a column set up for the date of birth but can't figure out how to get this figure.
View 2 Replies
View Related
Mar 6, 2013
I have created a booking system for a set of resources for schools. Most schools have a membership which entitles them to 2 free sets. I have a booking form with a membership subform (membership table), and a booking details subform (kitloan table).
Once a school is selected on the main form, the membership subform shows the most recent record for that school based on schoolID.I want to display the number of sets they have already had within their membership period (can start at any time of the year, and lasts for 1 year) on the membership subform, so we know how many free ones they have left.
I therefore need to count the number of KitBkID (ID of the booking) in the Kitloan table where SchoolID = the SchoolID displayed on the membership subform, and the DateOut (booking date on kitloan table) is between the DateJoined and DateRenewal displayed on the membership subform (from membership table).
I can do this with a query which works when run and provided with the parameters SchoolID, DateJoined, and DateRenewal.
SELECT Count(Kitloan.KitBkID) AS CountOfKitBkID, Kitloan.SchoolID, Kitloan.DateOut
FROM Kitloan INNER JOIN Membership ON Kitloan.SchoolID = Membership.SCHOOLID
GROUP BY Kitloan.SchoolID, Kitloan.DateOut
HAVING (((Kitloan.SchoolID)=[Me].[SCHOOLID]) AND ((Kitloan.DateOut) Between [Me].[DateJoined] And [Me].[DateRenewal]));
What I can't do is get it to run on the form and take those values from the form.From the searching I've done, I'm thinking a DCount should be the way to go, but I cannot get the criteria right. I created a query (KitloanCountQry) so that criteria could come from both the kitloan and membership tables.
SELECT Kitloan.KitBkID, Kitloan.SchoolID, Membership.DateJoined, Membership.SCHOOLID, Kitloan.DateOut
FROM Kitloan INNER JOIN Membership ON Kitloan.SchoolID = Membership.SCHOOLID;
I have put the DCount as the control source for a textbox on the Membership subform (but have tried it in VBA too):
=DCount("KitBkID","KitloanCountQry")
This works but obviously gives me the total for all bookings.
[code]....
Although I have to admit to getting lost in the syntax. This produces #Error.
View 6 Replies
View Related
Nov 19, 2012
I am building a database and am trying to automate month names and years to appear in my table upon adding a new record. I have the code built to input the data I am calling from other tables, and have functioned it to work on a button click. Now I want the record to capture the current date and year everytime a new record is added and input that information into the respective fields.
View 3 Replies
View Related