Question Locked

SQL in MS ACCESS : Date handling

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

My table (tblStaff) has a date of birth field (DOB) defined as a 'General Date'.
I need to write a Query that counts those rows where the staff are under 25 years old, at run time. I am new to SQL, so can anybody advise on the syntax please ?
Many Thanks

4 replies

by grinder182533

I have solved this by using this coding :
DateAdd("yyyy", 16, DOB) <= Date() &
DateAdd("yyyy", 16, DOB) > Date()

by tony hopkinson

Select Count(*) From Staff Where DateAdd(year,25,DOB) < GetDate()

Few other variations

But DateAdd, DateSubtract ansd DatePart are along with GetDate()

are usually in there somewhere.

by grinder182533

Thanks Tony
I have learned a lot more about dates these last few days !

This discussion is closed to new replies.