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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Date finding

Author  Topic 

crazyme
Starting Member

11 Posts

Posted - 2006-08-11 : 07:04:02
I have a tutorial in which there is a question to find the person who will be celebrating their Birthday within a week.

The table contains : name, dob, sex

Thanks


Knowledge grows when shared...

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-08-11 : 07:07:18
Do you have a question?

CODO ERGO SUM
Go to Top of Page

crazyme
Starting Member

11 Posts

Posted - 2006-08-11 : 07:21:27
The question is...

"Who are the person who will be celebrating their Birthday within a week?"

Hope i'm clear now.



Knowledge grows when shared...
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-08-11 : 07:28:33
Something like this...

Select * from Table x, (select name, dateadd(yyyy, datediff(yyyy, dob,getdate()), dob) as CurrDate from Table) y
where x.name = y.name and datediff(wk, y.CurrentDate, y.CurrentDate+7) = 1


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page
   

- Advertisement -