Re: QUERY CALCULATION BASED ON DATE RANGE?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



> WHERE DueDate <=DateAdd(Date,"m,",-2) ? should read something like

WHERE ShipsInformation.[Date of Issue] <=DateAdd("m",-2,Date()),

and should be placed at the end of your SQL after the FROM line.

Two mistakes/potential problems. You got the syntax for DateAdd backwards, and you referenced an alias. Access does not always like it when you reference alias's, for purposes of criteria, sorting, etc. it is safest to reference the original field, not the alias.






Liam.M@xxxxxxxxxxxxxxxx wrote:

Hey guys,

If someone could spare the time in helping me with this problem it
would be very much appreciated...and apologies if it seems like a very
basic questions, however, I do not possess the experience and knowledge
like many of the people on here, and very much appreciate your
assistance.

I need to modify my SQL Statement to filter out all the records that I
am not interest in, bascially I need this query only showing records
that fall within a certain Date range...based on my "DueDate"
field......

The SQL Statement is as follows:

SELECT ShipsInformation.[SBMA Number], ShipsInformation.[Vessel Name],
ShipsInformation.[IMO Number], ShipsInformation.[Date of Issue],
ShipsInformation.RecordID, ShipsInformation.[Date of Attendance],
DateAdd("yyyy",1,ShipsInformation.[Date of Issue]) AS [Due Date],
ShipsInformation.EmailAddress
FROM ShipsInformation;

Now I understand that I need to add a "WHERE" criteria for the date
section....I want this query to only show records that fall within the
next two months of the "Due Date"....so something along the lines of :
WHERE DueDate <=DateAdd(Date,"m,",-2) ?


If someone could please explain how I could implement such a Query it
would be much appreciated...

Kind Regards


Liam.

.



Relevant Pages

  • Re: Subquery with invalid column name runs
    ... Queries first try to reference the nearest column, ... Scoping rules in SQL are similar to the scoping rules in block ... But SQL is a bit more complicated. ... If two query expression are on the ...
    (comp.databases.ms-sqlserver)
  • Re: Help with computing dateTime between previous record
    ... I have the SQL query you sent working, now how do i adjust the end result? ... Bring all the required fields from the first reference in the grid. ... FROM tableName As a INNER JOIN tableName AS b ...
    (microsoft.public.access.queries)
  • Re: A query that joins 2 tables
    ... halves of the query in the Design Grid, and then copying the text from the ... SQL view of each and pasting either side of the "UNION" operator. ... > SELECT Company, Product, Reference, Price ...
    (microsoft.public.access.queries)
  • Re: Problem referencing a field in a query
    ... I only see one reference to a table in your SQL statement's FROM clause, ... When I run out of things to tweak/change in a query, ... > I'm not sure what you mean if having included the row source for the chart ...
    (microsoft.public.access.gettingstarted)
  • Re: Books reviewed
    ... Roff (a heckuva ADO reference). ... > the Compact Framework can't be left out of any must have list. ... > Not everyone using the compact Framework will be using SQL Server CE,but ...
    (microsoft.public.dotnet.framework.compactframework)