Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Select people older than 65

$
0
0

Hi Guys,

I'm quite new to sql. I want to make a query that retrieves al the data from people that are 65 and older. Here's what i've tried so far

 

select

 

[Name]

[Cl]

[date_birth]

[EML]

from

[db].[dbo].[table]

WHERE

DATEPART(MONTH, date_birth)=DATEPART(MONTH,DATEADD(YEAR,'[^65]%',getdate()))

AND

DATEPART(YEAR,date_birth)=DATEPART(YEAR,DATEADD(YEAR,'[^65]%',getdate()))

Also tried to add LIKE before '[^65]% but didn't work.

When i just write just -65 i get all the people that are 65 but not older. What's wrong in this query?


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>