Web Development

Our forums are currently in maintenance mode and the ability to post is disabled. We will be back up and running as soon as possible. Thanks for your patience!

Question

Locked

SQL in MS ACCESS : Date handling

By grinder182533 ·
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

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

SQL in MS ACCESS : Date handling

by grinder182533 In reply to SQL in MS ACCESS : Date h ...

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

Collapse -

Try this

by Tony Hopkinson In reply to SQL in MS ACCESS : Date h ...

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.

Collapse -

SQL in MS ACCESS : Date handling

by grinder182533 In reply to Try this

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

Related Discussions

Related Forums