Grabbing month/day out of a date field.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Zamees
Forum Newbie
Posts: 19
Joined: Mon Oct 06, 2003 11:27 am

Grabbing month/day out of a date field.

Post by Zamees »

I'm attempting to get everyone who has a birthday.

My code runs a SQL statement where it tries to grab the month and day from the age field.

when i do

WHERE age = '2000-01-30"'

It returns results

How do I return all results WHERE age = '01-30'

I tried stristr(age,'01-30')
and substr(age,5,5)

But both of those return nothing. So whats the correct way to do this?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I just answered something very similar to this.

viewtopic.php?t=17453
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Try :
WHERE age LIKE '%-01-30' in the query ?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Or you can do:

Code: Select all

WHERE DAYOFMONTH(age) = DAYOFMONTH(NOW()) AND MONTH(age) = MONTH(NOW())
Mac
Post Reply