View Full Version : date problems


stu-dent
04-15-2004, 09:55 AM
hi im new here an am a student in northants, uk. i am haveing problems with the date options in queries for my coursework.

i have to create a data base for a tyre company. and so far in my data base i have got a car details table which has a date innit sayin when the tyres were fitted.
i have to create a query that can search for cars that had tyres fitted a year ago (the query is run monthly) i was told to use

date: date() - 365

by the teacher but it doesn't work and cant get it to work so any help would be appreciated.

ps i dont think i explained very well so if u cant understand just tell me and i will try to explain in

dcx693
04-15-2004, 10:42 AM
date: date() - 365

Perhaps your teacher should tell you that using a reserved VBA word as the name of a query column is generally a bad idea. Try

FitDate: date() - 365

If that doesn't help, please post the SQL of your query, and/or tell us what you're expecting to see and what is being returned by the query. Also post sample data and output if that makes it clearer.

stu-dent
04-15-2004, 01:02 PM
sorry i dont think i explained properly.

i am making a query that is run every month to show all car details that have had new tyres fitted in that month a year ago.
for example
(car details table)

car registration, tyre type, date fitted
BO03BOI, 165/80S14, 01/04/2003
YO03YOT, 165/80S14, 13/04/2003
GO03TOY, 165/80S14, 01/05/2003

i am aiming to use the current date (15/04/2004) to try to search for all cars that had new tyres fitted a year ago, but the query is run monthly so i would need to find all cars for that month (april) a year ago.
which should be

BO03BOI, and YO03YOT

..i just dont have a clue what i need to get this calculation to work

Jon K
04-15-2004, 02:26 PM
Put these in two new columns in the query grid:-

---------------------------
Field: Year([Date Fitted])
Show: uncheck
Criteria: Year(Date())-1

---------------------------
Field: Month([Date Fitted])
Show: uncheck
Criteria: Month(Date())

---------------------------

stu-dent
04-16-2004, 04:30 AM
yaayy it works..lol
thanks jon k you have helped me a lot :cool: