Queries :: Using Max With A Date?
Oct 8, 2013
I have a query where the intent is to return the most recent Statement Closing Date by Account Identifier.This works great
SELECT [ME - Balances and Activity at Cycle End_Updated].[Principal Bank Identifier], [ME - Balances and Activity at Cycle End_Updated].[Account Identifier], [ME - Balances and Activity at Cycle End_Updated].[Member Number], Max([ME - Balances and Activity at Cycle End_Updated].[Statement Closing Date]) AS [MaxOfStatement Closing Date]
FROM [ME - Balances and Activity at Cycle End_Updated]
GROUP BY [ME - Balances and Activity at Cycle End_Updated].[Principal Bank Identifier], [ME - Balances and Activity at Cycle End_Updated].[Account Identifier], [ME - Balances and Activity at Cycle End_Updated].[Member Number];
However, when I introduce variable data, such as a balance field where the balance is different every Statement Closing Date, I get everything.
My question is how do I get my query to return just the most recent Statement Closing Date, regardless of the variable data?
View Replies
ADVERTISEMENT
Aug 19, 2015
I have a table that has entries recorded with date and time in one field, and I want to have a query that returns all records of a specified date or date range, regardless of the time in the field.
I have tried
Code:
Between [StartDate:] And [EndDate:]
And
Code:
Between [StartDate:] & "00:00" And [EndDate:] & "23:59"
Neither of which work ....
View 13 Replies
View Related
Jul 11, 2014
I currently have a query set up which responds and filters by the date.
I use the current code in the criteria on the query for todays date less 7 days
Code:
DateAdd("d",-7,Date())
This works perfectly and I had no problem with it. However I need to adjust the criteria so it is less than 7days ago OR OLDER....
How would I go about doing that?
View 4 Replies
View Related
May 7, 2013
I am using the following expression to calculate a completion date for a project which is based on the due date. My problem that I am running into is when I get to a project that is due on a Tuesday, it returns a date for Sunday when it should be Friday.
IIf(Weekday([Due Date])=2,DateAdd("d",-4,[Due Date]),DateAdd("d",-2,[Due Date]))
View 3 Replies
View Related
Apr 26, 2013
I have a query based on a table which has a date field. the field both in the table and the query have the time also in the date value so when I try to query on a date I get nothing if I copy the date and time from the field I will get the result for that record if I just use the date I get nothing. I have tried the format which does display just date but if you click on the field the time is also there You must be able to query for a date only and get all the records.
View 11 Replies
View Related
Apr 20, 2015
I've two fields to work with:
[Date of Device]
[DischDate]
If i was explaining it, it would be as follows:
If [DischDate] Is in the next month after [Date of Device] then Y else N.
to add for example if the [Date of Device] is April 2015, and the [DischDate] is also April then i'd expect a N answer
to add for example if the [Date of Device] is April 2015, and the [DischDate] is May then i'd expect a Y answer
View 2 Replies
View Related
Aug 8, 2013
I have a query where I display the [OPEN DATE] and [CLOSE DATE] of my cases. However, when I run this query sometimes the cases are not closed yet, therefore there are null values. However, I also have a field to calculate the datediff between these two dates. I need the [CLOSE DATE] field to display today's date when it is a null value so that I can still get a count of the days using datediff when I run the query.
View 1 Replies
View Related
Nov 5, 2013
The query is there to query data, not to edit data or manipulate data in anyway. However, I am disgusted by the appearance of the date picker when I pick a field that is a date field.
Is there a way to hide/remove these date pickers from the query sheet?
Within the table itself I turned the "Show date picker" property to "Never" but that didn't make a difference.
View 2 Replies
View Related
Mar 26, 2013
I've attached a stripped down version of a small order database I'm working on.
A user would enter an order, the amount and the date the order is required by.
As you can see from tbl_seasons, the business has financial periods that match the first and last 6 months of each year. Each season has a start date and end date.
What I'm trying to build are two queries:
1. A query which lists all orders and has an extra field which shows the "season_id" that the order (date) relates to (based one the start date and end date in tbl_seasons)
2. A totals query which shows the total order amounts by season
how I might build these 2 queries.
View 2 Replies
View Related
Feb 24, 2015
I have a crosstab queries which uses the date query parameters. However, when I go to my Export command (code is below), it ask me to enter the date parameters (start date and end date) twice. What do I have to do so that the system will ask me to enter once only?
Code:
On Error GoTo Err_cmdTest_Click
'Must 1st set a Reference to the Microsoft Office XX.X Object Library
Dim dlgOpen As FileDialog
Dim strExportPath As String
Const conOBJECT_TO_EXPORT As String = "qryEXPORT"
[Code] .....
View 9 Replies
View Related
Feb 23, 2015
How can you export cross tab queries by using date parameters (for example: Jan 1, 2014 to December 31, 2014)...
View 3 Replies
View Related
Jun 19, 2015
I have 5 queries that I am running. The first query has the date range parameters set in the field area that I need to run and each additional create table query is based off the results of the previous query.
1. Which is better to use to run all of the queries in one simple step? A macro or a form? I am exporting the final table to excel so that I can make some additional adjustments off of it.
2. How would I setup the date range parameters for the first query if I were to use a macro without going into the query itself and updating the date field? I tried setting up a macro to run the queries by using the OpenQuery action for each of the 5 queries, but I cannot figure out how to do the date range.
View 11 Replies
View Related
Mar 12, 2015
i have 2 tables.. 1 with bookings and 1 with a BonusPeriod range.
in the Bookings table there is a field called [ServiceDate]
in the bonus table i have a field called [Period] which is text i also have 2 dates, [StartDate] And [EndDate] i need to Dlookup the Bonus table to return the value of the period table based on where the [ServiceDate] falls.
i dont want to use VBA (i really need it to work within a query that inserts it's data into another table)
i've tried everything but had no joy
Expr1: DLookUp("[Period]","BonusPeriods","[ServiceDate]" Between "#[StartDate]#" And "#[EndDate]#")
Expr1: DLookUp("[Period]","BonusPeriods","[Staff_BookingsAndQuotes_Master].[ServiceDate]" Between "#[StartDate]#" And "#[EndDate]#")
Expr1: DLookUp("[Period]","BonusPeriods","(FormatDateTime([ServiceDate]),"yyyy-mm-dd") Between (FormatDateTime([BonusPeriods]![StartDate]),"yyyy-mm-dd") and (FormatDateTime([BonusPeriods]![EndDate],"yyyy-mm-dd"))))
View 10 Replies
View Related
Mar 13, 2014
I have a database with date and time each stored in a separate field. Now I want to query the database based on a start date/time and an end date/time. I started with the code below but it only returns events within the same time range on each day when what I really need is every event from a specified date and time through a specified date and time.
SELECT myTable.ID AS myTable_ID, myDate, myTime, FirstName, LastName
FROM Staff INNER JOIN myTable ON
Staff.ID = myTable.StaffID
WHERE myTable.myDate >= #3/2/2014#
AND myTable.myDate <= #3/3/2014#
AND myTable.myTime >= #8:00PM#
AND myTable.myTime <= #11:00PM#
ORDER BY myDate desc
In the above example what I want is every event from 3/2/2014 8:00PM until 3/3/2014 11:00PM. But what I get instead is every event between 8:00PM and 11:00PM on 3/2/2014 and every event between 8:00PM and 11:00PM on 3/3/2014.
View 4 Replies
View Related
Mar 17, 2015
I have a table, tblVisits, holding patient's pre and post surgery visits:
Code:
PatientID VisitDate
1 1/5/12
1 3/10/12
1 9/1/13
2 ...
And another table holding patient's surgeries (each patient will have only one surgery)
Code:
PatientID SurgeryDate
1 4/1/12
2 ...
I need to compare these two tables and create a variable that indicates which pre-surgery visit date (i.e., VisitDate < SurgeryDate) is closest to the surgery date. In the above example, it would return:
Code:
PatientID VisitDate ClosestToSurgery
1 1/5/12
1 3/10/12 Yes
1 9/1/13
2 ...
I've tried various MIN and MAX approaches and can't seem to get it right.
View 2 Replies
View Related
Nov 3, 2014
running 3 queries together.
1 qry has a date parameter of start/end date(running before the 3 are together)
Have a field in 1 of the 3 queries with a date field that I need to show being <= the date parameter...
How/where do I use this criteria?
View 3 Replies
View Related
Jan 9, 2006
Hi everybody,
I have a report that is based on an underlying query.At the query level,I
want to define parameters of date data type so that records to be displayed
should fall between DateA and DateB. ie Between[Enter Date A:] And [Enter Date B:].
I want the DAteA and DateB to be only days and Months of a year.
Say my DateA = 01 Jan 06 and my DateB = 31 Dec. 06
But I want only the Parameter to be Between[Enter day and Month A:] And [Enter day and Month B:].
How can I write a query with the two parameter values?
Thank you
dfuas
View 1 Replies
View Related
Jun 28, 2005
I have a table that stores date/time in the Now() format, but I want to run a query that will format the date/time in "mm/yyyy" with MSAccess SQL.
Here is an example table:
Table1
------
IDDate
11-Dec-2004 12:24:06 PM
24-Apr-2005 5:04:18 PM
38-May-2005 8:13:52 PM
413-May-2005 2:27:57 PM
Here are the desired results:
Table1
------
IDDate
112/2004
204/2005
305/2005
405/2005
View 1 Replies
View Related
Oct 4, 2007
I have a query that pulls out a date. It's value is 05/10/2007 as DD/MM/YYYY
Then I do a basic sql statement via a recordest with this code
UPDATE TempValues SET LastShippingDate = #05/10/2007#
The problem is the way it gets stored in the table. I see it as 10/05/2007 DD/MM/YYYY.
The format field for that field is short date DD/MM/YYYY. Regional setting for this computer is DD/MM/YYYY.
Totally at a loss on this one :(
View 4 Replies
View Related
Jan 24, 2007
Hi
I am looking for ways to sort date columns.
Something like find all in one particular month, or year.
I know i have done this before to sort data into monthly queries,
but now i have forgotten
>> something like ="#*/7/*#" to sort all date on the 7th month.
By the way I cannot seem to get access to format dates in the
dd/mm/yy format, does anyone know if there is an option for this.
cheers
View 2 Replies
View Related
Jun 19, 2015
I have a qry which gives me this data:
date/code/hrs/amount
12/05/15 ABC 4 243.55
12/5/15 DEF 6 707.12
13/05/15 ABC 1 101.01
etc..
I'd like to sum the amount for each date. Is this possible?
I will be updating the table with new dates and want to eventually create a form where i set the dates and it does the query where I get the amount for the dates specified, e.g. 01/07/20 - 08/07/20
View 1 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
Jun 17, 2014
All using 2010. I have a query that the date is based on the Saturday after that current day and is entered in manually. Is it possible to automate this with code that says whatever the current date is; to adjust to the next Saturday date? I know its a long shot but I just wanted to see if I can eliminate user input.
View 7 Replies
View Related
Jun 3, 2013
I have a query the result of which provides me a date field in the format 12-Oct-2010.I want that this field data to be converted to corresponding numbers such as 40463.
View 5 Replies
View Related
Nov 10, 2013
I have 3 tables: Company, Client and Status. The Company/Client combinations can have various statuses over time (I use the field Rstatus in the Status table), including the values pass and fail.
Companies are assigned statuses for Clients periodically. Statuses could be eg:
Company A, Client 1, 01-01-2001, pass
Company A, Client 1, 02-01-2001, pass
Company A, Client 1, 01-09-2001, fail
Company B, Client 1, 01-02-2001, fail
Company B, Client 1, 01-03-2001, pass
Company C, Client 1, 01-03-2001, pass
I would like to make reports that will tell me:
1. All historical records for a given company/client combination at a given date (in history). Which statuses did we have at date xyz?
2. Of which company/client combinations the latest status was pass at a given date. For Client 1, which companies had Rstatus pass at date xyz?
View 7 Replies
View Related
Aug 23, 2005
Hello,
Am posting this message (also on reports forum) as i dont know whether the problem is at report or query level. Hope you can help.
Hello all, this is probably simple but im new to all this!
I am trying to produce reports that show details for only the past year, at present my reports are bringing up details of all the previous years also. Is there any way you can put conditions on reports ( or should it be in a query) that tells the report to only include dates i.e. today - 365 days. At present i have to change the dates every day both a start and end date. Is this possible?
Thanks
View 2 Replies
View Related