Question : DateTime Comparison in Access 2000

The parameter the user entered is a date, however, the added_on is a datetime value, how can I truncate the added_on to become a date value?
Code Snippet:
1:
2:
3:
SELECT MAINTENANCES.period, MAINTENANCES.vehicle_no, MAINTENANCES.date, IIf([TYPE]='C',[PRICE],0) AS CONTRACTOR_COST, IIf([TYPE]='G',[PRICE],0) AS GARAGE_COST, MAINTENANCES.material_cost, MAINTENANCES.shop, MAINTENANCES.hours, MAINTENANCES.description, 0 AS SPARE_PARTS_COST, 0 AS TYRES_COST
FROM MAINTENANCES
WHERE [Enter Start Date dd-mon-yyyy] <= MAINTENANCES.added_on AND MAINTENANCES.added_on <= [Enter End Date dd-mon-yyyy]

Answer : DateTime Comparison in Access 2000

Your method will work but is clumsy and complicated; it makes no sense to apply DateValue on the parameters as they contain no time part (except if the user types it which you ask her not to do).

The solution is to strip the time part from added_on. As this is SQL, the simple and fast way to do this is to apply INT.
Also, you should specify the parameters as shown below.

/gustav
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
PARAMETERS
  [Enter Start Date dd-mon-yyyy] DateTime,
  [Enter End Date dd-mon-yyyy] DateTime;
SELECT 
  MAINTENANCES.period, 
  MAINTENANCES.vehicle_no, 
  MAINTENANCES.date, 
  IIf([TYPE]='C',[PRICE],0) AS CONTRACTOR_COST, 
  IIf([TYPE]='G',[PRICE],0) AS GARAGE_COST, 
  MAINTENANCES.material_cost, 
  MAINTENANCES.shop, 
  MAINTENANCES.hours, 
  MAINTENANCES.description, 
  0 AS SPARE_PARTS_COST, 
  0 AS TYRES_COST
FROM 
  MAINTENANCES
WHERE 
  INT(MAINTENANCES.added_on) BETWEEN 
    [Enter Start Date dd-mon-yyyy]
    AND 
    [Enter End Date dd-mon-yyyy];
Random Solutions  
 
programming4us programming4us