Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
micky--4444
Starting Member
19 Posts |
Posted - 2009-10-23 : 12:19:20
|
| Hi,My database has a date of birth field 'DOB' datetime datatype.The table is 'users'I am trying to construct an SQL statement that will retrieve all the users that are between say 25 and 40.My thinking is:Select * FROM Users WHERE [DOB] Between TodaysDate-40years AND TodaysDate-20yearsI just don't know how to construct a valid SQL statement from that.any ideas? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-10-23 : 12:28:04
|
| Select * FROM Users WHERE [DOB] >= DATEADD(yy,-40,GETDATE()) AND [DOB] <= DATEADD(yy,-25,TodaysDate) |
 |
|
|
|
|
|