0

i have the following request :

Find people with more than 79 Years and 3 Month.

Suppose i have 3 persons with the following datebirth :

1941-01-01
1941-04-01
1941-12-01

How to get the one that my request need ?

Thank you

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

1

Something like this?

DECLARE @ThresholdDate DATE

-- go from "today" (SYSDATETIME), and subtract 79 years and 3 months from that date
SELECT @ThresholdDate = DATEADD(MONTH, -3, DATEADD(YEAR, -79, SYSDATETIME()))

-- now select everyone with a birthday before that date
SELECT (list-of-columns)
FROM dbo.YourTableNameHere
WHERE BirthDate <= @ThresholdDate;
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459