Reputation: 3189
Initially I have a specific column to store age
in my Table and I use the following to perform the select query
select count(*) from DonorDetails where age < 25
Now I have removed the age column and used dob
column (with Date/Time datatype) instead. How should I write the count query which gives the same result as before ?
Upvotes: 1
Views: 149
Reputation: 97131
In the Immediate window, you can use DateSerial
with a mix of other date functions to give you the date 25 years ago from today.
? DateSerial(Year(Date()) - 25, Month(Date()), Day(Date()))
2/22/1989
So in your query maybe you want something like ...
WHERE [DOB] > DateSerial(Year(Date()) - 25, Month(Date()), Day(Date()))
Upvotes: 3
Reputation: 4312
Here is a sample of how your SQL should look:
SELECT count(*)
FROM DonorDetails
WHERE (((DateDiff("yyyy",[dob],Date()))>25));
Upvotes: 1