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 |
|
sambrown180
Starting Member
38 Posts |
Posted - 2008-11-26 : 12:15:23
|
| Hi I am running a query to find customers who are under the age of 18, 15,12. These will all be run seperately. I was thinking the code would be along the lines of:select *from customerwhere dateOfBirth <=getdate() and then somewhere involve the amount of days e.g. 6570 for under 18.5475 days for under 15 and 4380 days for under 12. However im not sure how these would be put into the code? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-26 : 12:18:36
|
| [code]select *from customerwhere dateOfBirth <=dateadd(yy,-18,getdate())--for 18 yearsselect *from customerwhere dateOfBirth <=dateadd(yy,-15,getdate())--for 15 yearsselect *from customerwhere dateOfBirth <=dateadd(yy,-12,getdate())--for 12 years[/code] |
 |
|
|
sambrown180
Starting Member
38 Posts |
Posted - 2008-11-26 : 12:32:07
|
| for some reason the results do not come back with people under 18 they seem to be all over 18? |
 |
|
|
sambrown180
Starting Member
38 Posts |
Posted - 2008-11-26 : 12:35:57
|
| dont worry all sorted finally done something my self thanks |
 |
|
|
|
|
|