Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function date

Status
Not open for further replies.

dcampo

Programmer
Jun 13, 2006
71
0
0
EC
Hi all

Sorry, I don't write very well the english!!!

I have in my Database a table called Users. I have a field of containt the date of birth of all the users.

If I want to show the users that TODAY is their birhtday or the users that in the MONTH are birthday....

For example:

TODAY:
Linda McCantion 3 October
Daniel Campo 3 October
.
.

MONTH (example October)
Linda McCantion 3 October
Daniel Campo 3 October
Lady Rushell 5 October
Andrew Lennon 20 October
.

How can I do it? Any sentence for compare the date of birth with the date of today??

please, help me!!!

Thanks
 
to select the users who have birthday today:

Code:
select * from yourtable
where date_of_birth = today;

to select the users who have birthday in the current month:

Code:
select * from yourtable
where month(date_of_birth) = month(today) 
  and year(date_of_birth)  = year(today);
 
Today:
SELECT * FROM Users
WHERE DAY(DateOfBirth)=DAY(TODAY) AND MONTH(DateOfBirth)=MONTH(TODAY)

Month:
SELECT * FROM Users
WHERE MONTH(DateOfBirth)=MONTH(TODAY)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
hehe,

true, birthdays do not occur only once in life :))

thanks for the *BANG*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top