View Single Post

   
  #7 (permalink)  
Old 02-28-2008, 08:08 PM
Igor Raytsin
 
Posts: n/a
Default Re: Need help with MS SQL query

I didn't test it, but you'll get the idea:

SELECT Name, birthday, DATEDIFF(yy, birthday, getdate()) as years_now,
DATEDIFF(yy, birthday, (getdate() +30) ) as years_will_be
FROM table
WHERE DATEDIFF(yy, birthday, getdate()) < DATEDIFF(yy, birthday, (getdate()
+30) )


-----
Hope this helps


"Fred Thompson" <fredr@aol.com> wrote in message
newsISAb.456981$HS4.3574769@attbi_s01...
> I'm using MS SQL 2000 server. I have a table which includes a date field
> which has people's birthdays in it. How can I write a query to return all
> the records of people with birthdays within the next 30 days? (Based on
> system date as the starting point.) Actual year of birthday is

irrelevant.
> Also the next 30 days may span into the next month, or the next year.
>
>



Reply With Quote