Re: QUERY CALCULATION BASED ON DATE RANGE?

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



Apologies Phil....I have now fixed the problem....Kind Regards

Liam

p.s: thankyou so much for your assistance it is very much appreciated!

Lia...@xxxxxxxxxxxxxxxx wrote:
Hey Phil, thankyou so much for your prompt reply! I have tried to
implement this, however I am getting a few different error messages
My SQL Statement looks like this:

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],FROM
ShipsInformation; WHERE ShipsInformation.[Date of
Issue]<=DateAdd("m",-2,Date());

I once of two errors appearing...one: The SELECT statment includes a
reserved word or an argument name that is mispelled or missing, or the
punctuation is incorrect...or two: Characters found after SQL
Statment....any suggestions?

Regards

Liam

Phil wrote:
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: Error messageORA-00979: not GROUP BY expression
    ... > I'm writing an application on a Oracle 8 database in combi with the ... The OLE DB provider is Microsoft for Oracle. ... > When I replace manually the parameter:BU to a string in the sql statement ...
    (borland.public.delphi.database.ado)
  • Re: Copy data from excel to a defined table in another spreadsheet
    ... If you use ADO to get data using an SQL statement, ... >> Regards, ... >> Tom Ogilvy ... >>> table in another spreadsheet. ...
    (microsoft.public.excel.programming)
  • Re: executereader fails with sqlclient
    ... Turns out the problem was with my SQL statement after ... > Ricard Blewett - DevelopMentor ... > with regards, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Make count = 0 where no row is returned.
    ... > solution on Google so apologies for asking again. ... > Any pointers or the complete SQL statement would be appreciated. ... Prev by Date: ...
    (microsoft.public.access.queries)
  • Re: Primary Key Creation
    ... Regards ... >>1) I am creating a table with a SQL statement that takes data from another ... >>2) I have a link to an Excel worksheet range. ... > could link to the ODBC table or the spreadsheet and Append the data. ...
    (microsoft.public.access.tablesdbdesign)