Check for 7 days before birthday....

# Thread: Check for 7 days before birthday....

1. Member
Join Date
Dec 1969
Posts
81

## Check for 7 days before birthday....

Here&#039;s the problem I&#039;m having. I have database records containing birthdays for users. I want to query for all user&#039;s whose birthday is 7 days from today&#039;s date.<BR><BR>Example: today is 8/8/03, want to display all users whose birthday is 8/1/xx. It&#039;s easy if the year was the same, but I want all records regardless of the year.<BR><BR>Thanks in advance.<BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: Check for 7 days before birthday....

select bday from &#060;table&#062; where <BR>&#039;Sql Server<BR>Month(bday) = Month(GetDate()) AND Day(bday)-7 = Day(GetDate())<BR>&#039;Access<BR>Month(bday) = Month(Date()) AND Day(bday)-7 = Day(Date())

3. Senior Member
Join Date
Dec 1969
Posts
11,247

## ok slightly wrong

select bday from &#060;table&#062; where<BR>&#039;Sql Server<BR>Month(dateadd(d, -7,bday)) = Month(GetDate()) AND Day(dateadd(d, -7,bday)) = Day(GetDate())<BR>&#039;Access<BR>Month(dateadd("d ", -7,bday)) = Month(Date()) AND Day(dateadd("d", -7,bday)) = Day(Date())

4. Senior Member
Join Date
Dec 1969
Posts
11,334

## What?

Why are you equaling the month? What if you were born 8/1? Your quiery wouldn&#039;t return true, no?

5. Member
Join Date
Dec 1969
Posts
81

## Hmm..thanks, the query is not returning anything,

Thanks!!

6. Senior Member
Join Date
Dec 1969
Posts
11,334

your wording.<BR><BR>Do you mean if today is 8/8, you want everybodys birthday whose is on 8/15?? Or is it 8/1?

7. Member
Join Date
Dec 1969
Posts
81

## RE: Hmm..thanks, the query is not returning anythi

oops..my response title got cut off.<BR><BR>The query is not returning anything, but I will play around with it. I see what you&#039;re trying to do in the SQL statement. Thanks again! =)

8. Member
Join Date
Dec 1969
Posts
81

## RE: Your example doesn't match

Hi Desert Ghost, you know what, you are correct, my initial post is incorrect.<BR><BR>What I want is if today is 8/8, I want everybodys birthday on 8/15. I guess I am confused myself! Sorry, too close to the weekend!<BR>

9. Senior Member
Join Date
Dec 1969
Posts
11,247

## See correction

You *know* I hit post to quick!

10. Member
Join Date
Dec 1969
Posts
81

## Thanks guys, I got it.

I used the last statement that White Knight posted and just changed the -7 to 7 and it worked like a charm!!<BR><BR>Thank you very much. Have a great weekend!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•