Dates And Queries
Aug 31, 2007
I need to create an expression that will limit the results of my query. I only want to display all records where 'Completed' date falls within the following criteria: Between the 1st April and the end of last month. I do not want to include this month, because by definitiion it is not complete - not a full month.
My head's just a bit mashed and I can hardly begin to work this out.
If you can help me out, I'd appreciate it.
If you have the time I would also like to find the average number of records completed per month as so will need to somehow determine the number of full months between the 1st April this year and today.
Thanks,
Owen.
View Replies
ADVERTISEMENT
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
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
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
Jul 21, 2013
I have written a large number of queries to gather data for a quarterly monitoring form. How do I replace the dates to update them for next quarter.For example I have written a query which counts the number of new members who started in the period 01/04/2013 to 31/07/2013. How can I change this (and the other 200 queries) without opening them all individually and manually altering it. Is there an Access equivalent of Word's Find and Replace?By the way I am using Access 2000.
View 11 Replies
View Related
Sep 15, 2005
I have set up an Attendance database at work, where a record is created for each member of staff when they are absent. The tables are set up as follows:
[tblStaff]: StaffID, FirstName, Surname, Team, JobTitle
[tblAbsence]: StaffID, StartDate, EndDate, Issue
What I want to be able to do is set up a query to search for a reason for absence on a certain date (btw my date format is set at dd/mm/yyyy). The problem I have is if the user needs to check a date in between the start and end date i.e. Start Date is 11/11/2005 end date is 11/12/2005 and the user checks on 01/12/2005 then this record will be found.
I know there is a simple way to do this but I can't seem to figure it out. Any help would be greatly appreciated!
View 2 Replies
View Related
Oct 26, 2013
I have an issue with the database im working on:
I want to filter a listbox on a form to a user defined range entered into two text boxes
I have tried entering this into a query for [Date of Breakdown] but when i do so the form goes is blank!?
Between [Forms]![frmMachineDowntime]![txtfromdate] And [Forms]![frmMachineDowntime]![txttodate]
I already have a filter for the query which filters the listbox to display results for a specific machine which works fine
I have attached the form, table, query in this post, how to achieve this.
How to avoid getting a blank form should their search return no results.
View 14 Replies
View Related
Apr 19, 2013
If i have a table with firstdate and lastdate, then i need a query were i can see all the dates between.
Firstdate: 16/05/2013
Lastdate: 23/05/2013
Need result in query:
16/05/2013
17/05/2013
18/05/2013
19/05/2013
20/05/2013
21/05/2013
22/05/2013
23/05/2013
View 2 Replies
View Related
Mar 6, 2014
I have two date fields. I want to subtract them to determine the number of days elapsed. The dates are in the following format: Dateserial (Year, Month, Day). When I subtract them I get 7670 as the result when the number should be 365 if they are a year apart. How can I subtract the dates in a query?
View 3 Replies
View Related
Feb 1, 2013
My form consists of a textbox with a selected date. I have a combo box with integers 1-15. I have a table with 15 people and their birthdays.
I am trying to find the birthdays after a selected date by the integer selected in the combo box. For example, if I select 2/1/2013, and pick 7 in the combo box, the subform should show me people with birthdays 2/1 through 2/8.
I have a query with a datediff function. This is my query expression Expr1: DateDiff("d",[DateofBirth],[Forms]![Calendar]![Text1]) The criteria is <=[Forms]![Calendar]![Combo3].
It displays some data, but it's not consistent at all. I'm hoping to fix this without any SQL changes or form code. But if that's what I need, I'll do it.
I'm using access 2010, and I'm fairly new at it.
View 1 Replies
View Related
Nov 9, 2006
Hello,
Hoping someone can help.
Im using Access 2002 to revise my SQL. But it seems I have an issue with the way dates are being interpreted by Access whilst using SQL mode for Queries.
I typed the following code to add a record to my database:
INSERT INTO pt_mstr (pt_part, pt_added)
VALUES ('TimsPart', 01/01/2005)
Sure enough it creates the record. But for the field 'pt_added', I get the value '0/01/1900 12:00:43 AM'. (Nb I exported the data to Excel and this is how it interpreted it.)
Changing the date I am inserting into the database only changes the time value of this enlongated piece of data.
I imagine I have missed something really simple here.
Hoping someone can help.
Tim
View 3 Replies
View Related
Aug 30, 2014
Can't figure out why dlookup will not work for me in a query for certain dates?
Simple example to highlight the problem:
Table1 -
Read_Date----Read_Value
31/07/14-------10
01/08/14-------20
03/08/14-------30
20/08/14-------40
Query based on this table with the following calculated field:
Expr1: DLookUp("[Read_value]","Table1","Read_Date=#" &[Read_Date]& "#")
Query output -
Read_Date-----Expr1
31/07/14--------10
01/08/14
03/08/14
20/08/14--------40
Will not return a value for 01/08/14 or 03/08/14 (dd/mm/yy)
If you try it with many dates its skips several and I cannot see a pattern.
View 7 Replies
View Related
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
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
Mar 14, 2014
I've got two tables, both are indexed by customer ID, with a series of dates against the customer ID. One has a list of all dates a customer was visited, the other is a list of dates where activity happened on the customer account
I want to get a list of the dates when the customer was visited but where no activity happened on the customer account, i.e. where there is a customer visit date on the customer visit table but no record for that date on the activity table.
How do I do that? I can find all dates where was a date was on both tables, but how to find where its on one but not the other
View 2 Replies
View Related
Apr 22, 2013
I'm booking in my hotel booking system the start and enddate of renting a room.
Example: Room 12 is booked from (startdate) 16/05/2013 till (enddate) 19/05/2013.
Now i need a query where i can see all the dates between start and enddate.
Like:
Room 12 16/05/2013
Room 12 17/05/2013
Room 12 18/05/2013
Room 12 19/05/2013
This between function i really need.
View 1 Replies
View Related
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 2 Replies
View Related
Nov 15, 2014
I have a DB that consists of Movie titles and the multiple dates ( as many as 10) on which they will be used in the coming year.I built a flat table with 10 date fields.Then tried to build a relational table with just movie title and dates linked to ID.I cannot work out an ability to SEARCH the Database for a SPECIFIC DATE and get returned a listing of ALL Movie titles that will air on that date,
View 9 Replies
View Related
Aug 19, 2015
I am reviewing some old database methods and trying to achieve a text box containing the sum of values for items between two dates. At present it is done using a sub-form based on a query of a query.
At first a query collects the values between dates:
Code:
SELECT tblDespatch.Invoiced, tblOrders.Value
FROM tblOrders INNER JOIN tblDespatch ON tblOrders.ID = tblDespatch.JobDespatchID
WHERE (((tblDespatch.Invoiced) Between (DateAdd("m",-3,Date())) And Date()));
and then a secondary query generates the sum of the values:
Code:
SELECT Sum(qrySWBI03.Value) AS SumOfValue
FROM qrySWBI03;
This actually works perfectly but needs two queries and a sub-form for each bit of information and there twelve of them (quotes, orders and invoices for last 3, 6, 9 and 12 months).
View 4 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
Dec 11, 2013
I have a table containing a list of dates in "MMM YYYY" text format from "Jan 2010" to "Dec 2020".
I would like to restrict the list from the first record (Jan 2010) to the current month using today's date (eg in this case Dec 2013).
I know about
Code:
Format(Date(),"mmm yyyy")
And have tried the criteria
Code:
<Format(Date(),"mmm yyyy")
But doesn't work and haven't got much further....
View 6 Replies
View Related
Feb 19, 2014
Using Access 2007
Win 7
Total_Time: Format(nz(DateDiff("n",[Start],[End])/60))
This is my expression in a query.
I need to only show 2 decimal places in the results field.
View 6 Replies
View Related
Mar 26, 2013
We have vehicles which are lent out to employees on a daily basis,
I currently have a query shown as a report which vehicles are out between the given dates using this criteria in a query
>=[ENTER Start Date] And <=[Enter End Date]
what I want to be able to do is show which vehicles are NOT being used between these dates tried a few different ways but no success
View 5 Replies
View Related
Oct 14, 2014
I have created a query to limit the list in a combo box to display the months and years of the date field in a table. Below is the code that I am using. This works fine except this displays the years within the months - for example:
January 2012
January 2013
January 2014
February 2012
March 2012
March 2014
April 2012
May 2012
May 2014
I would much prefer it to sort by month and year:
January 2012
February 2012
March 2012
April 2012
May 2012
January 2013
January 2014
March 2014
May 2014
Code:
SELECT DISTINCT Month([QTDate]) AS MoNum, Format([QTDate],"mmmm yyyy") AS MoName
FROM MainTBL
ORDER BY Month([QTDate]);
How to change this code to make it sort on Month and Year, not just month?
View 3 Replies
View Related
Jun 12, 2015
I have a table with tasks in which are allocated to specific staff members. The start date of the task is currently inputted by the user and then an estimated time frame is inputted which automatically enters the planned end date.
When a task is complete a Yes/No box is ticked so that these tasks don't show up on the current list anymore.
I wondered if it is possible, for the second task allocated to a certain person to have the start date automatically inputted depending on the planned end date of the precious task.
So if the planned end date was 12/06/2015 then the start date of the next would be 12/06/2015 and so on.
View 2 Replies
View Related
Oct 22, 2013
I am having some "fun" at the moment trying to work out how to compare two times on different rows. The current setup I have is:
StartDTM EndDTM VisitID
09:00:00 10:00:00 1
11:00:00 12:00:00 2
12:15:00 13:00:00 3
etc etc...
I have found a SQL Query I have tried to use, however I am having no joy. The query is such:
WITH rows AS
(
SELECT *, ROW_NUMBER() OVER (ORDER BY VisitID) AS rn
FROM Data
)
SELECT DATEDIFF("n", mc.EndDTM, mp.StartDTM)
FROM rows mc
JOIN rows mp
ON mc.rn = mp.rn - 1
View 6 Replies
View Related