Query Problem

  • Thread starter Thread starter Steven Scaife
  • Start date Start date
S

Steven Scaife

I have a query where i want to select all records that are before a certain
month. We give all customers a support contract number, this is in the
format 000TM0204 where the last four numbers are the month and year it
expires. The query below gets the month and year and compares them to the
numbers the user enters. However the query has to be run twice, for
example. If i want to see all records that expired before july 94 i have to
enter 07 04 and have another query that looks for > the
Mid([company].[contract ID],6,2) so that it looks for any expirations after
july. Is there any way to get it so that it queries both ways at the same
time.

Thanks in advance for any help

SELECT Company.[Contract ID], Company.[Company Name], Company.[Tel Number],
Company.[Contract Type]
FROM Company
WHERE (((Mid([company].[contract ID],6,2))>[Enter a Month number eg for may
enter 05:]) AND ((Right([company].[Contract ID],2))<[Enter a year number eg
for 2002 enter 02:]));
 
Hi

Why not
SELECT * FROM COMPANY WHERE RIGHT(ContractID) = [EnterMonth]
, where the parameter EnterMonth is entered as 0204 or 0704 etc.
 
Back
Top